If the client's path on your site allows login/registration via social networks, receiving system emails (email confirmation), and paying via online payments — then you are familiar with the problem of «junk» sources in reports.
In all these cases, the client temporarily goes to another site, and when they return, they get a new source:
- Payment gate (bank's website, PayPal, webmoney, etc.)
- Email service (Yandex, Mail.ru, Gmail, etc.)
- Social network's OAuth service (accounts.google.com, facebook.com etc.)
Since reports are based on the last non-direct source, it turns out that the last artificially created source creates a new session and interrupts the advertising source that brought the user to the site.
In Google Analytics reports, all these sources are included in the channel referral
To avoid such problems, there are several ways to exclude traffic sources.
Google Analytics 4
In the new version of GA, this can be done in the Web Stream settings.
Go to Property -> Data Streams -> Web stream details -> More tagging settings -> List unwanted referrals
Here, the functionality is slightly more advanced, and you can exclude not only known sources, but also potential threats in the future.
For example, to exclude traffic from more than 500 payment gates added individually to Universal Analytics, just one exception in the form of a regular expression was enough:
.*(pay|acs|bank|secure|3d|card).*\..*
And sources in the form of various mail domains that occur when clicking on the mail confirmation link can be excluded with the expression:
.*mail.*\..*
Login via the google service is excluded like this:
.*accounts\.google\..*
Universal Analytics
If there are a limited number of sources and they are known in advance — they must be added to the Referral Exclusion List. This setting is located in the Property -> Tracking Info section.
Add an unwanted referral source to the table, and new sessions will no longer be attributed to it.
However, if the click — through from the excluded source occurred before the exception, and it is not interrupted by a new real source, conversions will be attributed to it even after the exception.
Google Tag Manager
If your GA code is hosted using GTM, then data about the referral source can be intercepted and rewritten before the data gets to GA.
Previously, GA had a feature for excluding a source for sessions with a tag utm_nooverride
. Now this functionality can be recreated using GTM.
Create a URL variable with the Query component and the utm_nooverride key — It will search for this label in all visited addresses.
Next, if you are using Universal Analytics, create a Custom Javascript variable with the following code:
function () {
if ('{{utm_nooverride}}' == '1') {
return document.location.origin;
} else {
return document.referrer;
}
}
Depending on the presence of the utm_nooverride tag in the page address, it will determine whether to return the address of the current page or the traffic source.
Next, in the settings of the Universal Analytics tag, you will need to add a field referrer
for which you can specify the Custom Javascript variable created in the previous step as the value.
To achieve the same effect using GA4 inside GTM, you need to change the content of the Custom Javascript variable to:
function () {
if ('{{utm_nooverride}}' == '1') {
return true
} else {
return false
}
}
а название подменяемого поля на ignore_referrer
Now, for those traffic sources that you can control, you need to add a label to the link that returns the user to your site?utm_nooverride=1
, and these traffic sources will no longer create new referral sources.