Sub topic 12
Consent and Privacy Considerations in GA4
Assume you already have a GA4 property, a web data stream, and a way to edit your site's code or tag manager. You should also understand basic HTML and JavaScript. This chapter explains how to collect useful data while respecting user choices and privacy rules.
Collect only what you need
Analytics data can include page views, events, device details, approximate location, and identifiers stored in cookies or browser storage. Before installing tags, decide which questions the data must answer. Do not collect personal information such as names, email addresses, phone numbers, or full URLs containing sensitive query parameters.
GA4 does not support sending personally identifiable information (PII). Remove or mask PII before an event reaches Google Analytics. For example, send an internal order ID instead of an email address. Review form fields, page URLs, custom parameters, and user properties.
A privacy notice should explain:
- What data the site collects.
- Why the site collects it.
- Which services receive it.
- How long data is retained.
- How users can change or withdraw consent.
Your legal requirements depend on the user's location, your organization, and the purpose of processing. Consult your privacy or legal team when required.
Consent mode and consent signals
A consent management platform (CMP) displays the consent banner and records the user's choice. Consent mode connects that choice to Google tags. It does not replace the banner or decide which laws apply.
The tag should receive a restrictive default before it loads or sends measurement data. After the user makes a choice, update the consent state. A common setup uses these consent types:
| Consent type | Controls |
|---|---|
| `analytics_storage` | Analytics cookies and related storage |
| `ad_storage` | Advertising cookies and storage |
| `ad_user_data` | Sending user data for advertising purposes |
| `ad_personalization` | Personalized advertising features |
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('consent', 'default', {
analytics_storage: 'denied',
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
wait_for_update: 500
});
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
function grantAnalyticsConsent() {
gtag('consent', 'update', {
analytics_storage: 'granted'
});
}
</script>The exact default and update rules depend on your CMP and applicable requirements. If consent is denied, do not manually send equivalent tracking data through another tool.
Privacy settings worth reviewing
Check these settings during property setup:
- Data retention: Choose the shortest period that supports your analysis. This setting applies to user-level and event-level data used in explorations and some reports. Aggregated standard reports can follow different retention behavior.
- Google signals: Enable it only when your privacy review supports the related advertising and cross-device features. It can affect reporting thresholds and user availability.
- User-provided data: Do not enable or configure it unless you understand the data flow, hashing requirements, consent rules, and applicable policies.
- Data deletion: Use the deletion feature when data was collected improperly or a valid request requires removal.
Check the implementation
Test each consent state in a clean browser session. Confirm that denied users do not receive analytics cookies and that granted users produce the intended events. Check the browser's network requests and GA4 DebugView. Also test withdrawal: changing consent should affect later collection, but it cannot automatically erase data already stored.
Exercise
A visitor denies analytics consent, but your site still sends a custom event with an email address. What should you change?
Show answer
Remove the email address from the event and prevent the event from being sent when analytics consent is denied. Then test the denied state in a clean browser session.