Google Analytics data messed up after installing CookieScript

Why is Google Analytics data messed up after installing CookieScript?

Nelson
Written by NelsonLast update 19 days ago

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.

You can also watch a video on how to connect Google Analytics 4 and CookieScript.

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.

2023-08-17 Update: When using Google Consent Mode, it is important to check the keep Google Analytics Cookies option in your banner settings. To activate this option, go to your banner settings > Behavior tab > Cookie Control section > mark the Keep Google Analytics cookies option. This will result in correct data in Google Analytics and keep your website compliant. This is the solution for problems like "double visits in Google Analytics".

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 the 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.

Did this answer your question?