- Chapter 13 – Google Analytics Self Referrals
Self Referrals are an issue, and self referrals can usually be caused by one of the scenarios.
- Client-side Redirects
- Untagged Web Pages
Client-side Redirect vs. Server-side Redirect
Consider the case below.
- You used to have an old URL m.example.com/page-A and you have been sending your users to this page.
- Then you have created a new page (m.example.com/page-B) to replace the Page-A. Now you are sending your users to page-B.
- However, there are many users who still are visiting your old page, Page-A.
To resolve this issue, you have set up URL direction from Page-A to Page-B. When your users visit Page-A, they will automatically be taken to Page-B. You can set up this redirect with a few methods.
|Server-side 301||Okay. http referrer header is preserved.|
|Server-side 302||Okay. http referrer header is preserved.|
|Client-side Redirect||Problem. http referrer header is not preserved.|
You can always use the Chrome browser’s built-in Developer Tool to verify if a redirect has been set up on the server-side as a 301 (or 302) redirect.
This line confirms it is a server-side redirect.
Status Code 301 Moved Permanently (from cache)
If you do not see the status code being reported as 301 or 302, then it is a client-side redirect.
- A client-side redirect happens with the browser itself.
- During a client-side redirect, Page-A and Page-B are loaded in succession, i.e. Page-A is loaded, and then it is followed by Page-B.
- This triggers two page views in succession without any click or interaction by a user, where the first page view (from Page-A) is never recorded by Google Analytics, and the source referrer (i.e. the previous page’s URL) is lost.
- Your Google Analytics will end up reporting your own domain name (i.e. self-referral) as a source which is incorrect.
On Page-A, you have this code in the <head></head> section that performs a client-side redirect in the web browser.
<head> <title>Page-A</title> <meta http-equiv="refresh" content="0;URL='http://m.example.com/Page-B'" /> </head>
- The meta element has the value of the http-equiv attribute set to “refresh” and the value of the content attribute set to “0” (meaning zero seconds), followed by the destination URL (i.e. the redirected URL) in which the browser is to request.
- The refresh time is set to zero seconds. Page-A is never displayed to the users before it is redirected to Page-B, which happened all on the client-side.
In practical when taking your users automatically from an old page to a new page, you should always only use server-side 301 (or 302) redirect. Server-side 301 (or 302) redirect preserves the referrer information which is good practice for web analytics.
Untagged Web Pages
Consider this scenario in which you have two pages on your website.
- Page-A has no Google Analytics tracking code installed.
- Page-B has Google Analytics tracking code properly installed.
A user lands on Page-A. While on page-A, this user clicks a link that takes him / her to Page-B.
- On Page-A, no Google Analytics tracking code has been triggered, and nothing is recorded by Google Analytics.
- On Page-B, Google Analytics starts a new session for the user, and assigns your own domain name to the source referrer.
This source referrer information recorded by Google Analytics is incorrect.
For good practice, you should always ensure installing your Google Analytics tracking code on all your web pages.
- Chapter 12 – Google Analytics Custom Reports
- Chapter 14 – Google Analytics Sampled Data
- Chapter 15 – Google Mobile App Analytics
- Chapter 16 – Google Mobile App Analytics iOS SDK
Gordon Choi’s Analytics Book has been available since August 2016.
Content on Gordon Choi’s Analytics Book is licensed under the CC Attribution-Noncommercial 4.0 International license.