Google Analytics Hack – obtaining full referring URL

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:


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
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

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:

Option 2) Place this code in the footer right before the tag:

(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 :

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 thoughts on “Google Analytics Hack – obtaining full referring URL

  1. 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.


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


  3. 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

  4. 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.

  5. 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.


  6. 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.

  7. 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?


  8. 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.

  9. 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?

  10. 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.

  11. 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

  12. 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.

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

  14. 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.

  15. 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.


  16. 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!

  17. 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

  18. 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

  19. 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.

  20. 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

  21. 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)
    2.usergroup-1-Unregistered / Not Logged In

    Have I done something wrong?


  22. 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?

  23. 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.

  24. 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?

  25. 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?

Comments are closed.