Google Analytics Hack – obtaining full referring URL

January 15, 2007 by reuben | Filed under Google, Google Analytics, SEO.

It’s so frustrating that you can’t usually find which forum thread is linking to your website, because under the referring site report, cross segment performance, content report, it truncates the URL at the end of the filename, so you end up with items like:

/forums/showthread.php
/forums/viewtopic.php
etc.

There are two options, the first is a hack which uses filters to place the referrer into the User Defined Report (thanks to tresman and Pyrana), while the second uses a modified version of the Google Analytics tracking code to place the full referrer into the Top Content Report.

Method 1 – User Defined Report

Add this filter to your Analytics profile:

Custom Filter
Advanced
Field A -> Extract A: Referral (.*)
Field B -> Extract B:
Output To -> Constructor: User Defined $A1
Field A Required: Y
Field B Required: N
Override Output Field: Y
Case Sensitive: N

Here’s a screenshot of the filter settings:
Google Analytics Filter Settings

Results:
User defined referrer tracking

Two of the major benefits is that you don’t have to mess with the Google Analytics code and it uses the User Defined Report which goes unused in most cases.

Method 2 – Hacking the Analytics Code

I managed to find a way to use the urchinTracker function to place the exact referring URL into the Top Content Report, use one of these options (not both!):

Option 1) Place the standard tracking code in the HEAD section of the page and use this body tag:
<body onload="javascript:urchinTracker(document.referrer);">

Option 2) Place this code in the footer right before the 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>

(Replace the XXX’s with your profile account number)

Here’s a quick screenshot of the results:
Analytics Exact Referrer Using urchinTracker hack

Once you run this report, you can then apply a filter at the top of “http” to only show the exact referrers.

The urchinTracker script is usually used for tracking javascript or Flash events :
http://www.google.com/support/analytics/bin/answer.py?answer=27229

Update: If you can’t edit the HEAD or BODY tag or want to keep the tracking code in the footer, check out the Google Analytics Full Referrer Update.

Update 2: 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.

Update: 5/10/07 – I confirmed that this hack still works with the new version of Google Analytics.

If you’re a webmaster about to do a redesign, you may want to look into some interesting free icons for your website.


83 Responses to “Google Analytics Hack – obtaining full referring URL”

  1. [...] Reuben Yau has come up with a great Google hack. You can now see the full url of a referring source. He has all the step by step instructions on his blog. Go check it out. Well done Reuben! [...]

  2. [...] Ein großer Nachteil von Google Analytics (neben der Preisgaben viel zu vieler Dazten an Google) ist Anzeige von verkürzten Referrer. Erhält man beispielsweise Links aus Foren, so kann man lange nach dem Beitrag suche, möchte man die genaue Unterhaltung rund um den Link lesen. Mit einen Hack von Reuben Yau kann man jetzt den gesammten Refferer anzeigen lassen, dazu geht man wie folgt vor: [...]

  3. [...] If you have any questions or ideas, join the thread over at SEO Refugee.read more | digg story [...]

  4. [...] Luckily Reuben Yau has come up with a hack that integrates the Urchin Tracker Script, which is usually used for tracking javascript or Flash events. It takes all of 1 minute to install and seems to be working great. If you’re a Google Analytics user and want full referring URLs – check out the fix at Reuben’s blog. Posted by Chris Winfield at 4:12 pm Bookmark this post: Bookmark this BlinkBits BlinkList Blogmarks Buddymarks CiteUlike Connotea del.icio.us Digg it Earthlink FeedMarker Flog this! feedmelinks Furl Give a Link Gravee igooi Lilisto Linkagogo Linkroll ma.gnolia Maple.nu My-Tuts Netvouz Newsvine Onlywire RawSugar reddit Scuttle Shadows Simpy Spurl Taggly tagtooga TalkDigger Wink Yahoo MyWeb « Why Are Apple’s Designs So Damn Sexy? |   [...]

  5. [...] Reuben Yau tells us how to make Google Analytics report the full URL for dynamic referrers. In other words, the referrer will show up as /forums/showthread.php?t=1234 instead of the useless /forums/showthread.php. This is a useful trick if you use Google Analytics; lack of dynamic URL reporting was a major reason why I switched to Mint last year. [...]

  6. [...] Reuben Yau got frustrated with not being able to see the full url in Google analytics, and now he managed to find a way to use the urchinTracker function to place the exact referring URL into the top content report. You can now see the full url of a referring source. He has all the step by step instructions on his blog. Click Here Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. [...]

  7. [...] /forums/showthread.php /forums/viewtopic.php etc. Reuben Yau found a great hack to pass this. 1) Make sure you place the standard tracking code in the HEAD section of the page, rather than right before the end BODY tag that it usually recommends. [...]

  8. [...] Google Analytics Hack: Gracias a ese truco podremos saber de que dirección exacta han enlazado nuestra web. Por ejemplo, cuando nos enlazan de un foro nos muestran: “foro.ejemplo.com/viewtopic.php” este enlace nos manda a todo el foro sin nada en concreto mientras que ahora mostraría: “foro.ejemplo.com/viewtopic.php?t=69344″ y ahí veríamos la página exacta desde la que nos han enlazado. [...]

  9. [...] Read about the interesting finding from PittBug at his Blog – Google Analytics Hack – obtaining full referring URL. [...]

  10. [...] Now there’s a hack.? It’s a bit ugly… but it’ll work if you don’t mind adding an onload event to your <body> tag. [...]

  11. [...] <body onload="javascript:urchinTracker(document.referrer);"> Here?s a quick screenshot of the results: Once you run this report, you can then apply a filter at the top of ?http? to only show the exact referrers. The urchintracker script is usually used for tracking javascript or Flash events : Google Analytics Help Center – What is urchinTracker and how can it help me? Source: Reuben Yau ? Blog Archive ? Google Analytics Hack – obtaining full referring URL [...]

  12. [...] Reuben Yau: I’m not a big fan of Google Analytics as it won’t give a simple transaction list, but Reuben has a great way to at least understand from where your traffic is really coming. [...]

  13. [...] I believe many users of GA has complained about this, but until Google releases news of an update with this feature, we can only suck thumb and wait. Otherwise, an alternative would be to head on down to Rueben Yau’s blog because he’s got a solution to address this issue. [...]

  14. [...] and wait. Otherwise, an alternative would be to head on down to Rueben Yau’s blog because he’s got a solution to address this [...]

  15. Is there a Certification for Google Analytics?

    Yes I posted about the certification requirements.

    Reuben

  16. [...] to force Google Anyalytics to give up the full referring url Google Analytics Hack – obtaining full referring URL – does just what it promises with a simple addition to any page’s body [...]

  17. Doesn’t the new interface for google analytics have this feature?


    Hi Heather

    No it still doesn’t include any parameters in the Referring Site report.

    Reuben

  18. Sooz says:

    Thanks for sharing info about this hack! I created the user defined report but can’t find it. What section of Google Analytics is it hiding in?

    —-

    Hi Sooz

    It’s under Visitors > User defined

    Reuben

  19. zden says:

    i think that you have to wait after google analytics counts some traffic using this filter… i think that this doesn’t have influence on statistics of earlier traffic

  20. reuben says:

    Hi zden

    Yes you’re right, when you apply a filter it only affects the reports ongoing.

  21. [...] you can either use Reuben Yau’s refferer hack, or you can also do this with user defined variables. You could simply add [...]

  22. zden says:

    You can do it the good way

    http://www.google.com/support/googleanalytics/bin/answer.py?answer=55511&topic=11032

    ——–

    i am not sure but it think that this does something else… it only makes full URL from your pages not referers

  23. reuben says:

    Hi zden

    That filter will show the full URL of the pages on your site within the reports. It won’t show the referring URLs.

  24. Hello Reuben,

    Thank you for this great article. It appears you know how to manipulate the GA JS. I was wondering if you knew of any way that can help me add custom fields to the tracking mechanism, to be able to report on them.

    Thanks!
    John

  25. reuben says:

    US Army Medals – I’m not taking on additional projects right now, but there’s a lot you can do with the utmsetvar function which can place specific values into the user defined report, here’s an example: http://www.google.com/support/googleanalytics/bin/answer.py?answer=57045

  26. volkan says:

    Hey Reuben,

    Thank you for this hack. I implemented the first method and it’s been several days since, and yet I have not seen any change in the User Defined stats in my GA page. I followed what you wrote here word for word and compared the screenshot to my setup, so I don’t understand why I don’t see the full urls. Is there any timeframe that I should wait before start looking for an alternative approach (maybe method 2.) Although, the method 1 is much cleaner, and I’d really like to stick with that.

  27. reuben says:

    Hi volkan, send me a screenshot of the set up page or set me up with a login to the account and I’ll take a peek.

  28. Jackson says:

    Hi Reuben,

    Thanks for this article!

    Quick question, aside from where you view the referring URLs, is there any other benefit from choosing Method 1 vs Method 2?

    Method 1 seems like the easier (and safer) choice. So I’m just wondering if Method 2 has any other advantages?

    Thanks!

  29. reuben says:

    Jackson: If you’re already using the user defined field for storing URL type info, then you could use method 2.

    If you’re not able to edit the analytics code, then you can use option 1.

    If you have access to the analytics code, then option 2 does give you a lot more flexibility as to which parts of your site you want to track referrers.

  30. Jackson says:

    That clears it up :) Thanks again Reuben!

  31. murat says:

    thank you for the useful trick reuben , i ll keep an eye on your blog

  32. [...] Yau)? ??? ? ?????, ?? ? ?? ???? urchinTracker ?? ??? ???? ? ??? [...]

  33. JT says:

    Hi Reuben,

    Thanks for this tip. I did exactly what you said and it works. But here’s the problem. The full referring URL is still not visible when it’s very long. If you put your cursor over it, you can see it, like an alt-tag of an image, but that doesn’t help if you want to visit the referrer URL.

    I tried View Source to copy and paste the referring URL, but it doesn’t show up in the visible code.

    If you turn the data into a pdf, you can see the referring url as text, but when you go to copy it, it breaks the text at the end of each line!

    Can’t you tweak the Google Analytics filter to convert the referral url into a text hyperlink for each referrer? I think website data programs do this. It would be very helpful.

    Do you know how?

  34. reuben says:

    Hi JT

    In the previous version of analytics you could expand the columns, but that feature is sadly lacking. I’ll see if there’s another way to do it and write up a post in a few days.

  35. Reuben – thanks so much for the detailed report & instructions. I’ve been wanting to add this forever, and never got around to Googling for it. Your post was the #1 result.

    Two other things:
    1) JT – if you export the results (PDF, CSV, etc.), the full URLs are there. Not as good as expanding the columns, but better than hovering over each one.

    2) Reuben – I’m curious to learn about *how* this works (like, for example, what does (.*) mean, and how did you know to put $A1 in the Construction field. Is there a tutorial on filters than you can recommend?

    Thanks again,
    -Brian Greenberg
    -http://www.familygreenberg.com/blog.htm

  36. Cacasodo says:

    Reuben,
    Thanks for the great link. I’ve implemented your Option 2 suggestion, by adding the urchinTracker(document.referrer); code to the GA tag within my pages. It works great; however, after I made the change last week, it looks like my Bounce Rate calculation has changed. Screen shot here:
    http://bp0.blogger.com/_bcLw_LVf5nA/R7xNkNOaa9I/AAAAAAAAAd8/zvCvlB5J9wI/s320/bouncerate.jpg

    did you notice this? if so, any solution?
    sodo

  37. mfsbo says:

    Thanks for the post.

    I implemented Method 1 and noticed that some of the URL directories appearing in the User Defined report was not appearing in the Referring Sites report. Has anyone else noticed that? and is there a particular reason why this would be happening?

    Also, for those directories that do appear on both sites, the statistics are different (i.e. Pages/Visit Time on Site, etc.).

    FYI: I do know that Referring Sites report does store the different query parameters in the string, and that to dive down into a directory, you must first click on the domain.

  38. mimsso says:

    Hallo, It’s a very interesting post. But in option 1 and 2 there is no code to copy ;) Where can I find It.
    Thanks!

  39. reuben says:

    Sorry about the missing code, it was there in the source, but when I upgraded to a new version of wp, the specific plugin that displays code wasn’t installed.

  40. [...] In particular, getting meaningful Referrer analsysis out of GA is a nightmare (I have no idea why we’re still having to hack in custom regexps just to get one of the most fundamental pieces of… – and note that the manual regexp additions still don’t work for a lot of sites: I’ve [...]

  41. Brilliant use of a filter in order to track this type of data. Does anyone know of a book that has the “best analytic” filters in it.

  42. lewis says:

    ACE BLOG MATE

  43. excellent article… just added it to the site and it works great

  44. Swords says:

    Thanks for the hacks. I’ve implemented the 1st one and I’m looking forward to seeing the results.

  45. [...] Google Analytics Hack – obtaining full referring URL, Google Analytics Hack – Full Referal URL [...]

  46. Alex says:

    Where do I see the results of the first method? I tried “Traffic Sources” -> “Referring Sites” and then changing the Source to “User defined value” but nothing showed up. The filter has been running for 2 days.

    Thanx!

  47. [...] Analytics Hack – obtaining full referring URL, Google Analytics Hack – Full Referal [...]

  48. Kyle says:

    Ace hack buddy thanks for the tips, this solves a very frustrating problem.

  49. [...] Credit: Reuben Yeu – Online Marketing and SEO Consultant Advanced Filter, Analytics basics, Google Analytics, Google Analytics [...]

  50. [...] Google Analytics hacks to obtaining full referring URLs – Provides two ways to get full referring urls into Google [...]

  51. Great article! Thank you I vote with two hands.
    I do not understand why google misses that info by default. Sometimes when a forum is referring traffic from different threads you can not track that. It was really annoying.

    Thank you so much for sharing this info!

  52. [...] here’s a quick tip that’s going to get you a lot of bang for your buck: Set up a User Defined Report to Obtain the Full Referrer URL from Google Analytics. Follow the link to get easy step-by-step instructions (see Method 1). I’ve used this [...]

  53. Sebastien says:

    Great tip! I’ve been looking for something like this forever. I still don’t understand why Google doesn’t implement this by default… Thank you

  54. Sebastien says:

    Hi Reuben,

    I implemented method #1 yesterday but I can’t find the user defined report anywhere in my account. I feel like a total noob about that! I looked everywhere online and can’t find any info.

    Would you mind helping me?

    Thanks in advance

    Sebastien // @sebastienpage

  55. reuben says:

    Sebastien: Once you’ve selected an account and are viewing the reports, click on the visitors link in the left nav, then you should see User Defined as the last one in that list.

  56. Sebastien says:

    Duh! That’s strange because I could swear I looked over there several times. Anyways, it’s here now. Thank you very much for this great trick and for your help.
    Sebastien Page

  57. [...] I explain you this trick, let me give full credit to Ruben Yau for actually coming up with it. I also want to thank Ruben for replying to my comment/question on [...]

  58. [...] There are two ways one can address this issue: 1. Use the urchinTracker to record the whole URL. Link 2. Create a User-defined report by using Custom Filters. With Custom Filters you can manipulate [...]

  59. [...] Google Analytics Hack – obtaining full referring URL Podporte tento [...]

  60. Paul says:

    Hi there,

    I’ve used your method 1 (for two domains) and when I click user defined under visitors the value shown in the right pane is:
    1.(not set)
    and
    2.usergroup-1-Unregistered / Not Logged In

    Have I done something wrong?

    regards

  61. Lex dePraxis says:

    I can’t find the link to make User Defined Report (method 1) in my GA. Help please.

  62. Reuben – thanks for an awesome post :) The method one GA hack was just what I was looking for – so thank you very very much :)

  63. Ian Drake says:

    No, you didn’t do anything wrong. The filter only works on visits after you created it. So in the future, you’ll see the desired results.

    This seems like basic functionality. Why doesn’t GA have this out of the box?

  64. Olli says:

    Another, more simple method would be a userstyle / CSS-hack:
    http://userstyles.org/styles/19676

  65. [...] Google Analytics hacks to obtaining full referring URLs – Provides two ways to get full referring urls into Google [...]

  66. [...] Les hacks Google Analytics – Deux astuces vous permettant d’obtenir les adresses complètes des sites vous référant. [...]

  67. [...] uno de los filtros con Full Referring Path – Esto es un poco más extenso de explicar pero aquí os dejo la [...]

  68. [...] Google Analytics Hack – obtaining full referring URL [...]

  69. [...] How to Track the Full Referring URL in Google Analytics [...]

  70. [...] Google Analytics hacks to obtaining full referring URLs – Provides two ways to get full referring urls into Google Analytics. [...]

  71. [...] view full referrer links from the sites that send you traffic; [...]

  72. bizseo says:

    Hello, just setup the first method around 24h ago. The report is still the same. How much time should it take before it appears ?
    I really need that cause i use the same code on multiple domains.

  73. Dennis says:

    We have been using this trick for about 6 months and all of the sudden (April 18, 2010) we are not seeing the referring sites anymore. Everything shows up as “not set”.

    We made no changes to our set up (both in GA and our website).

    Any thoughts? Anybody experiencing the same thing?

  74. martin says:

    Hi Dennis, I’m experiencing the same problem from April 18th. No referral data anymore. I was using “Method 1 – User Defined Report”.
    Do you have any solution?

  75. babor_7uiu says:

    Thanks for sharing.It’s a great post

  76. videoport says:

    I have the same problem – I set it up several days ago – and still no changes – it says “not set”

  77. [...] Track full referring URLs – set up the advanced filter: [...]

  78. [...] often find that they get snipped off in your Analytics reports. This blog post shows you how to track the full referring URL without that data [...]

  79. [...] As successfully demonstrated by Andrew Shotland, he “adapted (aka “ripped off”) this great post from Sebastien Page” who in turn gives “full credit” to Ruben Yau. [...]