Ga4 privacy compliance

From Activer007/ordinary-claude-skills · View interactive version

Ga4 privacy compliance is an AI agent skill from the GitHub repository Activer007/ordinary-claude-skills. Expert guidance for GA4 privacy and compliance including GDPR, CCPA, Consent Mode v2, data deletion, and privacy settings. Use when implementing Consent Mode, ensuring GDPR compliance, handling data deletion requests, configuring consent banners, or implementing privacy-first tracking. Covers consen

How to use this skill

Skill file

GA4 Privacy and Compliance

Overview

GA4 provides privacy-focused features for GDPR, CCPA, and global privacy regulations including Consent Mode, data controls, and compliance workflows.

When to Use This Skill

Invoke this skill when:

Core Capabilities

Consent Mode v2

What is Consent Mode:

Google's API for communicating user consent status to GA4, Google Ads, and other Google tags.

Consent Parameters (v2):

  1. ad_storage
  1. analytics_storage
  1. ad_user_data (NEW in v2)
  1. ad_personalization (NEW in v2)

Additional Parameters:

  1. personalization_storage
  1. functionality_storage
  1. security_storage

Implementing Consent Mode

Basic Implementation (gtag.js):

Step 1: Set Default Consent State (BEFORE gtag.js)

<script>
  // Set default consent to denied
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}

  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'ad_user_data': 'denied',
    'ad_personalization': 'denied',
    'analytics_storage': 'denied'
  });

  // Configure GA4
  gtag('config', 'G-XXXXXXXXXX');
</script>

<!-- Load gtag.js -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>

Step 2: Update Consent After User Choice

// When user accepts all cookies
gtag('consent', 'update', {
  'ad_storage': 'granted',
  'ad_user_data': 'granted',
  'ad_personalization': 'granted',
  'analytics_storage': 'granted'
});

// When user accepts only analytics
gtag('consent', 'update', {
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'analytics_storage': 'granted'
});

// When user denies all
gtag('consent', 'update', {
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'analytics_storage': 'denied'
});

GTM Implementation:

Method 1: Using Consent Mode Template

  1. Install CMP Template (OneTrust, Cookiebot, etc.)
  2. Configure default consent in template
  3. Template auto-updates consent on user choice

Method 2: Manual GTM Setup

Create Consent Initialization Tag:

  1. Tag Type: Custom HTML
  2. Code:
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'analytics_storage': 'denied',
    'ad_user_data': 'denied',
    'ad_personalization': 'denied'
  });
</script>
  1. Trigger: Consent Initialization - All Pages
  2. Tag firing priority: 999 (fires first)

Create Consent Update Tag (on user acceptance):

  1. Tag Type: Custom HTML
  2. Code: gtag('consent', 'update', ...)
  3. Trigger: Custom event from CMP (e.g., consent_granted)

Regional Settings

EU-Specific Consent:

gtag('consent', 'default', {
  'ad_storage': 'denied',
  'analytics_storage': 'denied'
}, {
  'region': ['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB']
});

gtag('consent', 'default', {
  'ad_storage': 'granted',
  'analytics_storage': 'granted'
}, {
  'region': ['US-CA']  // California - CCPA
});

Consent Mode Behavior

When analytics_storage = "denied":

When analytics_storage = "granted":

Conversion Modeling:

When consent denied, GA4 uses:

Data Retention Settings

Path: Admin → Data Settings → Data Retention

Options:

Applies To:

Reset on New Activity:

GDPR Compliance:

Data Deletion Requests

User Right to Deletion (GDPR Article 17):

Deleting User Data:

  1. Admin → Data Settings → Data Deletion Requests
  2. Create Deletion Request
  3. Choose deletion parameter:
  1. Enter identifier value
  2. Choose date range or "All time"
  3. Submit request

Processing:

Best Practice:

IP Anonymization

GA4 Default Behavior:

Unlike Universal Analytics:

Google Signals

What It Enables:

Privacy Implications:

Enabling:

Admin → Data Settings → Data Collection → Google Signals

Recommendation:

Data Thresholds

What Are Thresholds:

GA4 applies thresholds to reports when:

When Applied:

Managing Thresholds:

Consent Management Platforms (CMPs)

Popular CMPs:

GTM CMP Templates:

Most CMPs provide GTM templates:

  1. Community Template Gallery → Search CMP name
  2. Install template
  3. Configure CMP settings
  4. Auto-updates consent to GA4

Example: Cookiebot Integration

  1. Install Cookiebot tag on site
  2. Install Cookiebot template in GTM
  3. Template auto-sets default consent
  4. Updates consent based on user choice
  5. No manual gtag('consent') needed

GDPR Compliance Checklist

CCPA Compliance

Requirements:

Implementation:

// Detect GPC signal
if (navigator.globalPrivacyControl) {
  gtag('consent', 'update', {
    'ad_storage': 'denied',
    'ad_user_data': 'denied',
    'ad_personalization': 'denied',
    'analytics_storage': 'granted'  // Analytics OK, ads denied
  });
}

GTM Variable for GPC:

  1. Variable Type: JavaScript Variable
  2. Global Variable Name: navigator.globalPrivacyControl
  3. Use in Consent Mode logic

Testing Consent Mode

Verification Steps:

  1. DebugView Test:
  1. Check Event Parameters:
  1. Cookie Inspection:
  1. GTM Preview:

Chrome DevTools:

// Check current consent state
dataLayer.filter(item => item[0] === 'consent')

Server-Side Consent

Measurement Protocol with Consent:

{
  "client_id": "client_123",
  "consent": {
    "ad_storage": "denied",
    "analytics_storage": "granted",
    "ad_user_data": "denied",
    "ad_personalization": "denied"
  },
  "events": [...]
}

Best Practice:

Integration with Other Skills

References

Quick Reference

Consent Parameters (v2):

Set Default (Before Consent):

gtag('consent', 'default', {
  'ad_storage': 'denied',
  'analytics_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied'
});

Update After User Accepts:

gtag('consent', 'update', {
  'ad_storage': 'granted',
  'analytics_storage': 'granted',
  'ad_user_data': 'granted',
  'ad_personalization': 'granted'
});

Data Deletion:

Admin → Data Deletion Requests → Create

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.