Skip to content
Academy ofAI Learning

Store / Growth Setup Pack

Claude skill · Marketing and growth

GA4 and consent mode

GA4 and Tag Manager with consent mode v2, a lawful banner, one key event per goal, data checked.

When Claude uses it (the skill's own description)

Set up Google Analytics 4 and Google Tag Manager for a site with consent mode and a lawful UK or EU cookie banner, define the key events that match the business goal, and check the data is real. Use when asked to set up analytics, install GA4 or GTM, add conversion tracking, fix "no data" or double-counting, or make tracking compliant with cookie rules. Works through a browser tool, the site's code, or screenshots.

growth-setup-skills/skills/ga4-and-consent-mode/SKILL.md

The skill, as Claude reads it

Plain text you can open, read and edit. The first part is shown.

# GA4 and consent mode

The aim is a small number of events that match the business goal, measured once, with consent handled properly so the numbers are lawful and comparable over time. Not "track everything".

## Collect first

1. **The goal**: what a visitor does that matters (buy, enquire, book, sign up). That becomes the key event.
2. **The site**: platform, who can edit the head of every page, whether a tag manager is already present (look for gtm.js and gtag.js in the source; two of either means double counting).
3. **Where the business is and who visits**: UK and EU visitors need consent before analytics cookies are set.
4. **Other tools to link**: Google Ads, Search Console, Meta pixel.
5. **Internal traffic**: the office's and the owner's own IP addresses or a test cookie, so their visits are excluded.

## Set up

### 1. Accounts and property
- One GA4 property per site, named after the site, with the right time zone and currency. Data retention set to 14 months.
- A web data stream for the canonical domain. Enhanced measurement on, but turn off anything that creates noise (form interactions on sites with no forms, video on sites with no video).
- Google Signals only after consent is handled.

### 2. Tag Manager, one container
- One GTM container on every page, in the head, loaded through the consent script (below) so it respects the choice. Remove any hard-coded gtag.js that would duplicate it.
- GA4 configuration tag firing on Consent Initialization or All Pages, after consent defaults are set.
- Variables for page path, click text, form id, and the values a purchase needs (value, currency, transaction id).

### 3. Consent mode v2
- Before any tag loads, set defaults denied for ad_storage, analytics_storage, ad_user_data and ad_personalization (and functionality and personalization storage as the banner defines them).
- A banner that asks before setting non-essential cookies: two equal choices (accept, reject), no "accept" by scrolling, a way to change the choice later, and a record of the choice. The GOV.UK cookie banner pattern is a good model: plain words, equal buttons, a confirmation line.
- On a choice, update consent and store it for a sensible period (six months to a year). Send the update before the first page_view.
- Test with the Tag Assistant: with consent rejected, no analytics or ad cookie is set, and GA4 receives only cookieless pings if you choose to allow them.

### 4. Key events
- One key event per real goal: purchase (with value and transaction id), generate_lead, sign_up, book_appointment. Mark them as key events. Everything else stays an ordinary event.
- Fire each from the thank-you state or a server-confirmed success, never from a button click alone.
- De-duplicate: one event per transaction id. Check in DebugView.

### 5. Links and exclusions
- Link Google Ads (import key events as conversions, with enhanced conversions where there is an email) and Search Console.
- Define internal traffic and filter it. Add a referral exclusion for the payment provider's domains so a purchase is not attributed to "stripe.com".
- Cross-domain measurement if the checkout lives on another domain.

### 6. Check the data is real
- DebugView while performing each key event once, from a clean browser.
- Realtime shows the page views; the key event appears with its parameters.
- Two days later: the key event count matches the business's own records (orders, enquiries) within a few percent. If not, find the double or the miss before anyone reports a number.

## Output

```
Property and stream: ids (not secrets), time zone, currency, retention
Container: id, tags, triggers, variables as a table
Consent: defaults, banner behaviour, storage period, what fires on reject
Key events: name, trigger, parameters, how de-duplicated
Links and exclusions: Ads, Search Console, internal traffic, referral exclusions
Checks done: DebugView results, realtime, the reconciliation date
Open items for the owner
```

## Rules
- Never set consent to granted by default for UK or EU visitors.
- Never put personal data (an email, a name) in an event parameter or a URL.

…

Also in the Growth Setup Pack