# Wave 62 — AI referral GTM owner checklist

**Audit:** `Zatra_AI_Referral_GTM_QA_Report_2026-08-11`  
**Container:** `GTM-KRB2CCP` · **GA4:** `G-0THQS9MDZS`  
**One-page owner pack:** [AUTHORITY-STATUS.md](./AUTHORITY-STATUS.md) (do these 4 next)

---

## Do these 4 next (summary)

1. **Mode A DebugView** — confirm one `ai_referral` + one `generative_search_landing` via direct `gtag` (no GTM Event tags yet). Use `/tools/ai-referral-check/?utm_source=chatgpt.com`.
2. **Optional mode B** — draft GTM tags → remove AI keys from `GA4_DIRECT_EVENTS` + deploy → publish GTM (Steps 0–3 below). Never dual-send.
3. **NS → Cloudflare** before any apex cutover.
4. **Live fee / invoice spot-checks** on pricing.

Everything below is the detailed cutover recipe for item 2.

---

## Architecture decision (prevent duplicates)

| Mode | When | How events reach GA4 |
|---|---|---|
| **A — Direct `gtag` (current live)** | Until GTM Event tags are ready | `analytics-layer.js` → `dataLayer.push` **and** `gtag('event', …)` via `GA4_DIRECT_EVENTS` |
| **B — GTM-managed (recommended end state)** | After cutover below | `dataLayer.push` only; GTM GA4 Event tags send to `G-0THQS9MDZS` |

**Never run A and B together** — each event would count twice.

### Current live mode: **A**

Do **not** publish GTM GA4 Event tags for these two events until you complete the cutover to **B**.

---

## Code shipped (Wave 62) — no GTM UI access from agent

| Item | Status |
|---|---|
| AI Check helper syntax (`\n` inside quoted string → permanent “Running…”) | **Fixed** |
| AI Check schema (“Branch vs Subsidiary” contamination) | **Fixed** |
| Dormant structure-form / structure CSS on AI Check | **Removed** |
| `dataLayer` + detection + once-per-session (`zatra_ai_ref_sent`) | Unchanged / working |
| Direct `gtag` for AI events kept until cutover | Yes (mode A) |
| Cache bump `analytics-layer.js?v=20260811wave62` | Done |

---

## Owner — cutover to mode B (~15 min + one deploy)

### Step 0 — Prepare GTM in a **draft** workspace (do not publish yet)

1. **Data Layer Variables** (name = DL key): `ai_engine`, `utm_source`, `utm_medium`, `referrer`, `page_path`, `surface`
2. **Triggers:** `CE — ai_referral`, `CE — generative_search_landing`
3. **GA4 Event tags** (use existing Google tag for `G-0THQS9MDZS` — no second config tag):

| Tag | Event name | Trigger | Parameters |
|---|---|---|---|
| `GA4 — ai_referral` | `ai_referral` | `CE — ai_referral` | `ai_engine`, `utm_source`, `utm_medium`, `referrer`, `page_path`, `surface` |
| `GA4 — generative_search_landing` | `generative_search_landing` | `CE — generative_search_landing` | `ai_engine`, `page_path`, `surface` |

### Step 1 — Code cutover (remove dual-send)

In `assets/js/analytics-layer.js`, remove from `GA4_DIRECT_EVENTS`:

```js
ai_referral: 1,
generative_search_landing: 1
```

Bump cache query (e.g. `?v=20260811wave62b`), deploy `zatra-www` `--branch=main`, smoke AI Check.

### Step 2 — Publish GTM workspace

Publish the draft from Step 0 immediately after the deploy in Step 1.

### Step 3 — Acceptance test

1. Fresh private window (or clear `sessionStorage` key `zatra_ai_ref_sent`).
2. GTM Preview →  
   https://www.zatra.co/tools/ai-referral-check/?utm_source=chatgpt.com
3. Page shows **AI referral WOULD fire** with `session_already_sent: false` (not stuck on “Running…”).
4. Tag Assistant: both custom events **once** with correct params.
5. Each GA4 Event tag fires **once**; no second send from direct `gtag`.
6. GA4 DebugView: exactly one of each event name.
7. Reload same session → neither fires again.
8. Fresh sessions: `claude.ai`, `perplexity`, `gemini`, `copilot`, `grok`/`x.ai`, `you.com`.
9. Optional Insights URL:  
   https://www.zatra.co/post/gold-business-in-tanzania-2026?utm_source=chatgpt.com

### Step 4 — After publish

- Optionally mark both as key events / conversions in GA4.
- Exploration: landing page + `ai_engine` + WhatsApp / lead / Start Setup.

---

## Owner — mode A only (if delaying GTM)

1. Confirm DebugView receives both events via direct `gtag` (no GTM Event tags).
2. Leave GTM with **only** the base Google tag for `G-0THQS9MDZS`.
3. Skip Steps 0–2 above until ready for mode B.

---

## Do not

- Publish GTM Event tags while `ai_referral` / `generative_search_landing` remain in `GA4_DIRECT_EVENTS`.
- Add a second Google / GA4 Configuration tag for `G-0THQS9MDZS`.
- Re-point apex DNS as part of this wave.

## Related

- Ops helper: `/tools/ai-referral-check/`
- Earlier recipe: `docs/63-WAVE43-SOFT-DIFF-GTM.md`
- Engines: ChatGPT, Perplexity, Gemini, Copilot, Claude, Grok/x.ai, You.com
