What is Document Referrer (Google Analytics)

Disclosure: Please note that this article may contain affiliate links. You can read the full disclosure here.

Awhile back I ran into an issue that traffic coming from Tailwind would appear in my Google Analytics as Pinterest/Social and would not show me the URL of the pin that was sending the traffic.

I got digging around on Google and found instructions on setting up the Document Referrer, which is a Custom Dimension in Google Analytics that allows you to see the URL of the page the visitor was last on right before they came to your site.

This feature is not retroactive, so it will only show for new traffic after it is setup in your Google Analytics.

Recently the direct traffic has been increasing, and I compared the direct traffic to the “Document Referrer” and see the screenshot below, some of it is from our site, likely links that have the rel=”noreferrer…” attribute still set. But, interestingly there are links coming from Pinterest on the Android App and from Facebook.

Here is a screenshot of the portion of Traffic we can see that is coming from Direct on our main blog.

Screenshot of Direct vs Doc Referrer Traffic

If you want to setup the Custom Dimension Document Referrer I’ll show you how to do that with Google Tag Manager. There are other methods to set this up, but this is how we did it.

First you will need to add the Custom Dimension in Google Analytics

Sign into Google Analytics and click on the Settings cog at the bottom left of the screen to access the administration area.

In the middle column scroll down then click on Custom Definitions

Then click on Custom Dimensions

Screenshot of the admin panel options

Click on the button to Create New Custom Dimension

Screenshot of Click New Custom Dimension Button

Type in Document Referrer and keep the default setting hit, click Create

Add custom dimension document referrer

On the next screen, we won’t need this information for Google Tag Manager, you can just click Done.

Screenshot of the last screen click done

We will need to add a second Custom Dimension. Again click the New Custom Dimension button.

Type in Document Referrer Hostname, keep the default setting hit and click Create.

Again on the next screen, click Done.

Screenshot of adding the second custom dimension document referrer hostname

Take note of the index numbers for your Custom Dimensions we will use these in Google Tag Manager.

Check the index numbers

Login to Google Tag Manager

This tutorial assumes that you have an existing Google Tag Manager account, you will need to follow these steps to setup Google Tag Manager here.

Click on the Variables on the menu on the left side.

Screenshot of Left side menu

Click on the New Variable Button.

Name this variable Referrer URL

Click on the Lego icon and select URL as the type of variable.

From the component type drop-down select Host Name.

Under More Settings change the drop-down to {{Referrer}} click Save.

Screenshot of Referrer URL Variable

Open the Google Analytics Settings variable, this would be setup following the initial Google Tag Manager tutorial.

Click the little pencil icon on the top right.

Expand More Settings if it is not expanded.

Click the Add Custom Dimension button twice.

Here is where you will need to line up with the Google Analytics Custom Dimension Index number.

Check the index numbers

In my case the Referrer is index 1 and the Referrer Hostname is index 2, so I would enter
Index Value 1 and Dimension Value {{Referrer}}, you can also click the lego icon and pick the Referrer built-in variable.

In the second set of values.
Index Value 2 and Dimension Value {{Referrer URL}}, again you can click the lego icon and search through the list of variables for the Referrer URL variable that you created from the last step.

Then click Save.

There isn’t much to preview in this instance, so it is up to you if you want to Preview the changes first or just go right to Submit and Publish the changes.

Remember if you do go into Preview mode, to also Leave Preview Mode once you are done.

Screenshot of Preview Submit Buttons

Screenshot of Publishing the Changes

Once Published you have completed this tutorial. In the next few days you should be able to see data in your Google Analytics under the secondary dimension for Document Referrer.

Screenshot of Secondary Dimension Doc Referrer

If you have any questions or comments on this post, please feel free to leave a comment below.

Avatar for Tara, WP Blogger Assist

I have over 15 years experience in IT. Over this time: managing server infrastructure, building websites and more. This website is dedicated to helping WordPress bloggers with setting up their blogs and websites; optimizing fast page loading, SEO and social media marketing - such as; Pinterest, Facebook and more.

Leave a Comment