Google Analytics data messed up after installing CookieScript

Why does this happen? 

Google Analytics uses cookies to track visitor behavior on the website when a user browses from one page to another. Since CookieScript is designed to clear cookies before consent is given, installing the CookieScript consent banner can mess up the data in Google Analytics. Here are some common issues you can face: 

  • Most of the traffic is treated as a direct traffic
  • Significant increase in bounce rate
  • Some functions like e-commerce might show incorrect data

All of those issues happen because if the user doesn't accept Google Analytics cookies, he is considered as a new user on each page view. This results in the issues discussed above.

How can this be fixed?   

Option 1: Activate Google Consent mode

Google Analytics implements a special mode where no cookies are set by default. As a result, privacy regulations are not violated and most of the Google Analytics functions will work properly. Google Consent mode has some drawbacks since it's kind of a workaround, only aggregated information about visitors is collected. Check out our blog post about Google Consent mode for more information on how it works. We also have some instructions on how to implement Google Consent mode properly.

2022-03-03 Update: Our in-depth tests show that with Google Consent mode enabled, in most cases, visitors will not show up in Google Analytics at all unless they agree to the Google Analytics cookie category. In other words, using Google Consent Mode will result in incorrect data in Google Analytics. This is not something that can be fixed on the CookieScript end, we just send the data according to the official Google Consent Mode documentation. It is then up to Google Analytics to decide if this information should be visible in the reports. 

Some blog posts suggest this is because Consent Mode is still in the Beta stage and it might be fixed in the future. This issue is not specific to CookieScript, other Consent Management Platforms have the same issues with Google Consent Mode.

Important: If you are using Google Consent mode, do not block the Google Analytics script in the banner settings > Scripts tab or by adjusting the Google Analytics JS code manually. Consent Mode works under the hood and there is no need for extra measures to block Google Analytics. 

Options 2: Keep all Google Analytics cookies

CookieScript offers an option to just keep all Google Analytics cookies no matter if a user consents to cookie usage. Although this might look like a privacy regulation violation, some other Consent Management Platforms use this by default to avoid issues with Google Analytics data. 

To activate this option, go to your banner settings > Behavior tab > Cookie Control section > mark the Keep Google Analytics cookies option.

When activated, CookieScript will make sure Google Analytics cookies are never deleted. This option should only be used if Google Consent mode still does not provide the necessary data in Google Analytics.

When using this option, make sure you are not blocking Google Analytics in banner settings > Scripts tab. Also, make sure the Google Analytics script is not blocked manually.

Important: To avoid issues with privacy regulations, we highly recommend you to enable IP anonymization for Google Analytics

Further troubleshooting

There are a few extra things to check if you already use one of the solutions above, but data in Google Analytics is incorrect: 

1. Make sure you are not blocking Google Analytics in banner settings Scripts tab. Also, make sure the Google Analytics script is not blocked manually. Any of those will result in Google Analytics code to fire only if the user accepted the necessary category. All other users will be basically invisible for Google Analytics completely. 

2. Re-save your CookieScript item. We do periodically push some updates in the code that could improve the workflow of Google Analytics. To apply those updates to your banner, you have to re-save the banner. This can also be done for all banners by clicking the "Update all" button in your dashboard.

3. When using Google Consent Mode, make sure you remember to set Initial Consent State (this is done automatically if using GTM CookieScript Tag Template)

4. If you are using Google Consent Mode and include Google Analytics with Google Tag Manager, make sure you do not add any additional consent conditions to the default Google Analytics tag. Google Analytics Tag has a build-in ad_storage consent type validation.

Those are the most common issues when implementing Google Analytics.

Google Analytics and cookies

It's important to remember that privacy regulations aim is to allow users to opt-out from being tracked. This is the main reason complying with the Privacy regulations can make problems when using tools like Google Analytics. Google Consent mode is the preferred way to keep using Google Analytics and still be fully compliant with the privacy regulations. Read more about Google Analytics and Privacy Regulations.