Module causes Google Analytics to interpret traffic as direct instead of organic (no referrer)

Created on 24 November 2020, almost 4 years ago
Updated 22 October 2023, about 1 year ago

Problem/Motivation

(direct = straight from the browser's input field, organic = from search).

The GA script kicks in after the user clicks on "Agree" on the cookie compliance popup, and that's expected. However, when this happens, the traffic is interpreted as direct, even if the user has arrived at the site via search.

  • If the user has arrived at the website via search, the GA script will be executed after the user clicks on 'agree', interpreting the traffic as direct (wrong).
  • If the user has arrived at the website via search but has already agreed with the policy, GA script will be executed on page load, interpreting the traffic as organic (expected).

Steps to reproduce

1. Install the Google Analytics Debug extension on your browser and open the console;
2. Search for the website on Google;
3. Go to the website, agree with the cookie policy;
4. Watch the GA code be executed, on the console you should see no referrer variable on GA logs;
5. Repeat step 2;
6. Go to the website, on the console you should see the referrer variable on GA logs as google.com.

Apparently, after you click on 'agree', the GA script will have no referrer, even if you arrived at the page via search. If you've already agreed, the script will have a referrer. In this case, the GA script is being loaded by the Google Tag module.

This has a considerable impact on GA reports. Our client, for example, has shown very little organic traffic since we deployed the module months ago.

🐛 Bug report
Status

Closed: outdated

Version

1.9

Component

Code

Created by

🇧🇷Brazil RamonOliveira Denmark

Live updates comments and jobs are added and updated live.
  • JavaScript

    Affects the content, performance, or handling of Javascript.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024