Capture the Full HTTP Referrer in Google Analytics with a “Hit Referrer” Custom Dimension

July 29, 2015

This post is inspired by a discussion I had recently on the Google Analytics forum.

In Google Analytics there is a dimension for “referral path” and even “full referrer,” however the shortcoming of both these dimensions is that they only provide the Path of the referrer—no query strings. When analysis calls for details of a referrer, the full URI of the referrer is really helpful—query strings included. Additionally, the built-in Referral dimensions are sessionized, meaning they are populated only once per session. What if you want to know what the actual HTTP REFERRER field was on any given hit, such as a pageview or an event hit?

Enter a Custom Dimension for what I like to call “Hit Referrer”.

This dimension will provide the full, raw referrer on every hit, which is extremely useful for debugging and data exploration of both external referring sources and internal referrals between pages.

This post will rely on use of Google Tag Manager for setup of the referral hit capture. If you’re not using GTM, you should be!

Implementation takes just three steps.

Step 1: Create a Custom Dimension and set it scope to “Hit.”

Step 2: Create a Variable for Referrer in Google Tag Manager.

Confirm the Variable for Referrer is active in Google Tag Manager.  By default, GTM provides referrer.  To confirm if this is enabled and available to you, click to Variables in the GTM main nav and make sure the “Referrer” built-in variable is activated.

Step 3: Add the Custom Dimension to your GA hits.

Add the Custom Dimension to your GA hits. This is where things come together. You must be sure to add the same Custom Dimension to all GA hits (events, pageviews, etc…), and customize the index to your “Hit Referrer” dimension index.

The final product: a referrer for every hit!

Using Hit Referrer Data

What can you do with this data? A lot of great things….

  • Understand the full referring source URL for any given session.
  • Understand what page on your own site preceded the volume of traffic to any given page or event. While GA has a “next page path” field, this dimension is not available in all reports and it is based on the processed page hit sequence data. It doesn’t exist for Events, and it’s just not the same thing as a “referrer.” You could, conceivably, have a different “previous page path” from a referrer for the same pageview.
  • Better understand navigation of users from page to page on your site.
  • Identify pages on your site that aren’t tagged with Google Analytics.  By comparing all the “Hit Referrer” values that are on your domain to all the URL’s of pages from your own site that GA records under the “Page” dimension, you’ll be able to easily spot pages that are referrers that don’t show up as pages where hits are captured from, revealing pages that are un-tagged or have broken tags that aren’t working.

I hope this simple technique is useful to you and I welcome your feedback in the comments!