Forum Moderators: martinibuster

Message Too Old, No Replies

Tracking Script & document.referer

never got Referer?

         

zhenghua

12:18 am on Mar 14, 2004 (gmt 0)

10+ Year Member



Referers are never got, what's wrong with the code?


function TrackIt() {
if (window.status.indexOf('go to') == 0)
{
docref='na';
AdvertiserDomain='';
PageLocation='';
if (document.referer) docref=escape(document.referer)
if (window.status) AdvertiserDomain=escape(window.status.substring(6))
if (document.location) PageLocation=escape(document.location)
bug = new Image();
bug.src = 'trackScript.dll?loc=' + PageLocation + '&ad=' + AdvertiserDomain + '&r=' + docref ;
}
}
var elements;
elements = document.getElementsByTagName("iframe");
for (var i = 0; i < elements.length; i++) {
if(elements[i].src.indexOf('googlesyndication.com') > -1)
{
elements[i].onfocus = TrackIt;
}
}

I wonder if I am the only guy who never got the value of the referer. Please help, thanks!

[edited by: zhenghua at 12:23 am (utc) on Mar. 14, 2004]

zhenghua

12:20 am on Mar 14, 2004 (gmt 0)

10+ Year Member



After over 150 records, I only find "na" and nothing more about the document.referer.

zhenghua

12:22 am on Mar 14, 2004 (gmt 0)

10+ Year Member



The Tracking Script I mean is from [webmasterworld.com...] .

jomaxx

6:15 am on Mar 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're only doing the testing on your own system, maybe you have a firewall such as Norton that blocks the referer from being passed. Just a thought.

zhenghua

7:49 am on Mar 15, 2004 (gmt 0)

10+ Year Member



jomaxx, thanks, but the thing is, I really run this script on my website. and got over 200 records. then found all other info are tracked well, only document.referer remains nothing else. :-(

ari11210

3:23 pm on Mar 15, 2004 (gmt 0)

10+ Year Member



It seems to me that all of these tracking scripts use onFocus to check for the click on the iFrame. Doesnt onfocus also get called when the user uses the tab key to the tab through the iframe? Can this be the reason for the multiple clicks people are seeing? This can register a 'hit' in the tracking script although the user never clicked on the iframe. Does this make sense to anyone else? Is there a better way to check for the click on the iframe (onClick, etc)?

Aaron

richmondsteve

4:44 pm on Mar 15, 2004 (gmt 0)

10+ Year Member



ari11210, yes, there are a number of actions other than clicking to load the target URL which will trigger then onFocus event. A few of us pointed out several examples in this thread (I realize the thread is very long so you may have missed these posts).

too much information

4:49 pm on Mar 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I found the same problem. I think what is happening is that the referrer for the Iframe is the page that loads it, so the script doesn't do what it looks like it should.

You should try putting a Session cookie with the referrer on each page, then use the cookie to identify the referrer for each page when you write the click to your log file.

That would be the quick and easy solution.

zhenghua

2:31 pm on Mar 18, 2004 (gmt 0)

10+ Year Member



Finally I think I know the reason, this tracking javascript does not place inline with the page, I use a linked .js, thus the vaule of "document.referer" cannot transfer to the .js script. If I place the whole javascript at the every page can solve this problem.

zhenghua

2:50 pm on Mar 18, 2004 (gmt 0)

10+ Year Member



Okay, I first place following code at every page just blow the code of the GAS:

<script language="JavaScript" type="text/javascript">
<!--
if (document.referer) _ref=escape(document.referer)
//-->
</script>
<script type="text/javascript" src="/javascript/AdsenseTracking.js"></script>

Then, at the AdsenseTracking.js, do some modification as follows:


...
if (document.referer) docref=escape(document.referer)

if (typeof(_ref)!= "undefined") docref=escape(_ref)

if (window.status) AdvertiserDomain=escape(window.status.substring(6))

...

zhenghua

3:33 pm on Mar 18, 2004 (gmt 0)

10+ Year Member



One more question, should I use "var"?

[devedge.netscape.com...]

Otherwise, the document.referer cannot or can transfer to the linked .js?

zhenghua

9:54 am on Mar 19, 2004 (gmt 0)

10+ Year Member



A-ha!

In fact, because of the typo, all referer
should be referrer. That's all.