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:
/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:
![]()
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




Is there a Certification for Google Analytics?
–
Yes I posted about the certification requirements.
Reuben
You can do it the good way
http://www.google.com/support/googleanalytics/bin/answer.py?answer=55511&topic=11032
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
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
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
Hi zden
Yes you’re right, when you apply a filter it only affects the reports ongoing.
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
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.
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
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
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.
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.
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!
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.
That clears it up :) Thanks again Reuben!
thank you for the useful trick reuben , i ll keep an eye on your blog
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?
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.
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
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
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.
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!
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.
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.
ACE BLOG MATE
excellent article… just added it to the site and it works great
Thanks for the hacks. I’ve implemented the 1st one and I’m looking forward to seeing the results.
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!
Ace hack buddy thanks for the tips, this solves a very frustrating problem.
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!
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
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
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.
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
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
I can’t find the link to make User Defined Report (method 1) in my GA. Help please.
Reuben – thanks for an awesome post :) The method one GA hack was just what I was looking for – so thank you very very much :)
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?
Another, more simple method would be a userstyle / CSS-hack:
http://userstyles.org/styles/19676
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.
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?
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?
Thanks for sharing.It’s a great post
I have the same problem – I set it up several days ago – and still no changes – it says “not set”