Home > Google, Google Analytics, Tracking > Google Analytics Full Referrer Tracking Update

Google Analytics Full Referrer Tracking Update

February 15th, 2007 Leave a comment Go to comments

Since I wrote about tracking the full referrer in Google Analytics, I had feedback from some people saying that their content management system, forum software, etc doesn’t allow them to modify the HEAD section or BODY tag. Some other people are also hesitant to place the code in the HEAD section incase the Google Analytics servers are slow, causing the page to pause while the tracking code is downloaded from Google. Another drawback to putting the tracking code high up on the page is that you may end up counting partial page downloads.

So to get around these issues here’s an alternative which you can place just before the end BODY tag.

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-XXXXXX-X";
urchinTracker();
urchinTracker(document.referrer);
</script>

Just replace the XXX’s with your Analytics account code.

Update: I’ve augmented the tracking code to also detect if the page is served in http or https mode to serve the appropriate call to the urchin.js file, and also detecting whether the referrer is internal or external so you don’t get your site appearing as a full referrer in the Top Content Report. View my Ultimate Google Analytics Tracking Code.

Categories: Google, Google Analytics, Tracking Tags:
  1. April 11th, 2007 at 22:14 | #1

    Sweet!

  2. Yuri
    May 24th, 2007 at 04:06 | #2

    How to log the right ip if my application server is behind an apache proxy? I get the ip of the proxy in Google Analytics instead of the client ip, so the host statistics are wrong…


    Hi Yuri

    I don’t think it’s possible, you may want to try asking in google groups.

    Reuben

  3. July 26th, 2007 at 14:49 | #3

    Hi,

    Is it still working? Cause I tried but since I’ve added the code, Google Analytics indicates 0 visits :(

  4. July 26th, 2007 at 15:22 | #4

    thr0b: Yes it’s still working here. If you have multiple profiles, are you sure you’re pushing data to the right profile?

  5. November 8th, 2007 at 06:18 | #5

    It’s ok now but… I can’t see the full path of the referers. I mean, I just can see alias.domain.com or domain.com but not domain.com/forum/blabla…

    Is it because I’m stupid and I don’t go in the godd section in Analytics? :P Thank you ;)

  6. November 11th, 2007 at 10:04 | #6

    thr0b: Depending on which method you’re using, you either need to look in the user defined report, or top content.

  7. Sisupoika
    January 22nd, 2008 at 07:19 | #7

    Hi, thank you for your suggestion but I was wondering, won’t this affect the page views stat by recording twice one page view?

  8. May 15th, 2008 at 19:57 | #8

    I can’t see the code.

  9. June 30th, 2009 at 10:46 | #9

    Is this still working with the current Google Analytics?

  10. October 13th, 2009 at 07:33 | #10

    Hi there! Thanks for the workaround!I just want to point out that you can avoid all this if you use a web analytics solution that supports both Java script and log file tracking. One such solution is Logaholic Web Analytics and it really does wonders with segmentation and tracking. You can download a free trial from: http://www.logaholic.com/wp/trial-download/

  11. February 16th, 2010 at 12:15 | #11

    ohh, that helped me so much, thx bro

  12. Anes
    March 28th, 2010 at 11:32 | #12

    where is the line that returns the URL of the tracking code?

  1. No trackbacks yet.