How to set up consent for Google Analytics

Google Analytics (GA) tracks how people use your websites and mobile apps. It collects data like page views, location, time spent, and what users click on.

  • Page Views: The number of times a specific page on your site has been viewed, indicating content popularity and user engagement.
  • Location: Geographical data of your visitors, helping you understand your audience demographics and target your marketing efforts more effectively.
  • Time Spent: The duration users spend on individual pages and your site as a whole, reflecting content quality and user interest.
  • User Clicks: Tracking the elements users interact with, such as buttons, links, and forms, to optimize user experience and conversion funnels.

Because this involves personal data, laws like the General Data Protection Regulation (GDPR) in the EU and the California Consumer Privacy Act (CCPA) in the US say you can’t collect it without permission. That means Google Analytics must obtain user consent before collecting or storing data through cookies or similar technologies.

What do website owners need to do

If you're using Google Analytics, you should follow the following steps:

1. Don’t load Google Analytics by default.

Google Analytics uses cookies to track visitors. Because of privacy laws, you need to wait until a user agrees before loading it. If you load it right away, you're likely not compliant.

The easiest way to handle consent is with a CMP. It shows users a cookie banner and only runs Google Analytics if they click “Accept.” If you don’t have one installed, start with UniConsent. It provides a customizable consent banner, automatic blocking of tracking scripts until consent is granted, and straightforward setup by adding a script to your site's <head> section.

UniConsentUniConsent

To get started:

  1. Visit uniconsent.com

  2. Create an account

  3. Follow the setup instructions

  4. Add the provided script to the site

  5. Check that Google Analytics does not load before consent

3. Test the Setup

Before and AfterBefore and After

Once your CMP is installed: Open the site in a private browser window. Verify that Google Analytics does not run immediately. Click "Accept" and confirm that GA only begins tracking afterward.Tools like browser dev tools or Google Tag Assistant can help verify this.

4. Update the Privacy Policy

UniConsent Privacy PreferenceUniConsent Privacy Preference

Include clear information about:

  • The use of Google Analytics

  • The type of data being collected

  • The reason for collecting it

  • How users can change or withdraw their consent

The above are all the steps,It keeps the site in line with privacy laws and gives users real control over their data.