Tracking Visitors Who Reject Cookies: A Step-by-Step Guide for GA4
To track traffic from users who reject cookies or consent on your site while complying with privacy regulations, you can implement Google Consent Mode. This will allow you to gather basic analytics data (like sessions and pageviews) without using cookies.
Here is a step-by-step guide to track users who
reject cookies using Google Consent Mode in GA4:
Step 1: Set Up Google Tag Manager (GTM)
- Login
to Google Tag Manager:
- Go
to Google Tag
Manager and log in to your account.
- Select
the container for your website.
- Create
a Google Analytics 4 Tag:
- If
you don’t have a GA4 tag, create one:
- Click
"Tags" in the left-hand panel.
- Click
"New" to create a new tag.
- Choose
"Google Analytics: GA4 Configuration".
- Enter
your GA4 Measurement ID (you can find this in your GA4 Admin
settings).
- Leave
the default cookie settings as is for now.
Step 2: Integrate Google Consent Mode
Google Consent Mode works with a cookie consent management
tool (CMP) or manually adjusted consent signals. It adjusts tracking based on
the user’s consent, allowing partial tracking if cookies are rejected.
- Integrate
Google Consent Mode in GTM:
- Open
your GTM container.
- Click
on "Variables" in the left-hand menu.
- Scroll
down and click "Configure" under Built-in Variables.
- Enable
"Consent State" variables for ad_storage, analytics_storage,
and other relevant states.
- Add
Google Consent Mode Script:
- Modify
your website’s global tracking code to include the Google Consent Mode
script.
- Add
the following script to your website’s <head> tag:
html
Copy code
<script>
// Adjust consent
mode based on user input
gtag('consent', 'default',
{
'ad_storage': 'denied',
'analytics_storage':
'denied'
});
// Update based on
consent decisions
gtag('consent', 'update',
{
'ad_storage': 'granted',
'analytics_storage':
'granted'
});
</script>
- This
code sets Google Analytics to deny storage by default (for users
who do not consent) and updates it if the user grants consent.
Step 3: Set Up Consent Signals for Analytics Tracking
Now, you need to make sure GA4 will still track some data
even when users reject cookies.
- Go
to GTM:
- Navigate
to Tags > Google Analytics 4 Configuration.
- In
the tag settings, scroll down to the "Consent Settings"
section.
- Enable
Consent Override:
- Toggle
on "Enable Consent Overview".
- Set
the required consent signals for ad_storage and analytics_storage.
- For
users who reject cookies, consent will automatically default to
denied, but GA4 will still track anonymized sessions without cookies.
- Fire
Basic Pageview Tags:
- Click
"Triggers" > Select "All Pages".
- This
allows Google to track basic data like page views and bounce rates.
Step 4: Configure Cookie Consent Platform (CMP)
If you’re using a cookie consent management platform
(CMP), you need to integrate it with Consent Mode.
- Check
for Google Consent Mode Integration:
- Many
CMPs (like OneTrust, Cookiebot, or Quantcast) support Consent Mode. In
your CMP settings, enable Google Consent Mode and link it to your GTM
container.
- Consent
Banner Customization:
- Customize
your consent banner to trigger updates based on user consent choices.
- When
a user rejects cookies, the CMP should pass the denied consent
signal to Consent Mode.
Step 5: Configure Google Analytics 4 Reports for Consent
Mode Data
Google Analytics 4 will collect aggregate data from users
who reject cookies:
- Log
in to GA4 and go to Admin > Data Settings.
- Enable
"Consent Mode Reports" in GA4:
- GA4
has built-in capabilities to handle Consent Mode. In the reports section,
you will see data from users who have rejected cookies, such as
anonymized traffic metrics.
- Check
Your Reports:
- Navigate
to Reports in GA4 and view traffic metrics.
- You’ll
see anonymized data for users who reject cookies, including:
- Pageviews
- Bounce
rates
- Basic
engagement metrics (without personalized user identifiers).
Step 6: Test the Implementation
- Test
Using Developer Tools:
- Open
your website and use the developer console (Ctrl + Shift + I) to test the
behavior of Consent Mode.
- Visit
your site and reject cookies. Use the Network tab to ensure that
traffic events (such as page_view or session_start) are still sent to
GA4, but without any personal data or cookies.
- Test
in Google Analytics DebugView:
- In
GA4, go to the DebugView (found under the "Events"
section).
- You
should see the traffic being logged even when cookies are rejected.
No comments