Question Using a Referrer/UserAgent with WebBrowser

digitaldrew

Well-known member
Joined
Nov 10, 2012
Messages
151
Programming Experience
Beginner
Hey everyone, quick question... I'm trying to set a referrer in the webbrowser (either via referrer or useragent) but it doesn't appear to be working. I'm testing with Google Analytics and I can see my visit come in when I hit the homepage using the webbrowser, but it shows it as a "Direct" hit rather than the referrer I have set..

This is my code
VB.NET:
Me.wb.Navigate(lstURLs.SelectedItem, "", Nothing, "Referer: " & selectedReferrer & vbCrLf & "User-Agent: " & selectedUserAgent & vbCrLf)

Any idea what I could be doing wrong? Thanks!
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,583
Location
Norway
Programming Experience
10+
Have you debugged what values those expressions actually evaluate to?
I tested this with valid strings for url/referer/agent and both referer/agent is detected correctly at these two urls:
Referer Test
Browser UserAgent Test
 

digitaldrew

Well-known member
Joined
Nov 10, 2012
Messages
151
Programming Experience
Beginner
Hey John, thanks for your reply! I did debug to see what the values were and they appeared correct, although I noticed many of the useragents I was trying were extremely outdated. Could that have anything to do with it??
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,583
Location
Norway
Programming Experience
10+
Could that have anything to do with it??
I don't know, maybe GA validates the referral, ie checks that there is a link to current url from given referrer.
 

Herman

Well-known member
Joined
Oct 18, 2011
Messages
882
Location
Montreal, QC, CA
Programming Experience
10+
Some sites also protect against referer spoofing through their own proxy. This will be true of any website that checks referer to determine if you just saw a paid ad. Not much you can do to go around those.
 
Top Bottom