GA4 Tracking Plan - California Forever

Created: 2026-01-26 Status: In Progress

Overview

Set up Google Analytics 4 event tracking for the pledge form funnel on /breakgroundnow/ to measure conversion and engagement.

The Funnel

1. PAGE VIEW: /breakgroundnow/
   └─> User lands on pledge page

2. FORM START
   └─> User focuses on first form field

3. FORM FIELD TRACKING (detailed)
   └─> Track each field focus for abandonment analysis

4. FORM SUBMIT (PRIMARY CONVERSION)
   └─> Gravity Forms submission → redirect to thank you

5. THANK YOU PAGE VIEW: /breakgroundnow/thank-you/
   └─> Confirms conversion, split by zip (in-zip vs out-of-zip)

6. SECONDARY ACTIONS
   ├─> Quote form submit
   ├─> "Email your electeds" click (in-zip only)
   ├─> Social share clicks (FB/X/LinkedIn/Copy link)
   └─> "Return to break ground" click

Events to Implement

Event Name Trigger Data Attributes
pledge_form_start First field focus form_id
pledge_form_field_focus Each field focus field_name, field_order
pledge_form_submit Form submission form_id, zip_code
quote_submitted Quote AJAX success signer_id
email_electeds_click Button click city, zip_code
social_share_click Share button click platform (fb/x/linkedin/copy)

Implementation Approach

Using direct gtag() calls (not GTM triggers). GA4 automatically receives events.

Code Locations

File Events
inc/modules/page_modules/pledge_form.php Form start, field focus, submit
page-thank-you.php Quote submit, email click, social shares

Example Code

// Push to dataLayer for GTM (if using GTM)
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'event': 'pledge_form_start',
  'form_id': 'pledge'
});

// Or direct gtag() call (if using GA4 directly)
gtag('event', 'pledge_form_start', {
  'form_id': 'pledge'
});

GA4 Configuration Required

After code is deployed:

  1. Verify events appear in GA4 → Reports → Realtime → Events
  2. Mark as conversion in GA4 → Admin → Events → toggle pledge_form_submit
  3. Create funnel exploration in GA4 → Explore: - Step 1: page_view where page contains /breakgroundnow/ (not thank-you) - Step 2: pledge_form_start - Step 3: pledge_form_submit

GA4 MCP Server Setup

To enable Claude Code to query GA4 data directly:

  1. Install pipx: brew install pipx && pipx ensurepath
  2. Enable Google Analytics Data API in Google Cloud Console
  3. Create OAuth 2.0 Client ID (Desktop app)
  4. Authenticate with gcloud
  5. Add MCP server to Claude Code config

See: https://github.com/googleanalytics/google-analytics-mcp

Client Decisions

MCP Server Details

Google Cloud Project: GM-Analytics-MCP (455914529060) OAuth Client: Claude Code GA MCP Client ID: 455914529060-pa0b4u8f9f9cuo0urqbtr57df3tnibo9.apps.googleusercontent.com Credentials Location: ~/.config/google-analytics-mcp/client_secret.json ADC Location: ~/.config/gcloud/application_default_credentials.json

Claude Code Config: Added to ~/.claude/settings.json:

"mcpServers": {
  "google-analytics": {
    "command": "pipx",
    "args": ["run", "google-analytics-mcp"]
  }
}

Usage: Restart Claude Code to load the MCP server. Then use mcp__google-analytics__* tools.

Change Log

Mar 10, 2026: Analytics audit fixes applied. - A/B variant attribution: GF redirect now appends ?variant=A/B server-side so thank-you page reads it via PHP, not just cookie. Fixes misattribution in privacy/incognito mode. - Hero share buttons on thank-you page now tracked as thankyou_share_click (previously only the navy section was captured). - email_electeds_click now includes city param. - quote_submit now includes zip_code param (matches quote_form_start). - GA4 dashboard actions.js updated to query quote_form_start. Dashboard redeployed.

Next Steps

  1. [x] Set up GA MCP server for Claude Code access
  2. [x] Write tracking code for pledge_form.php
  3. [x] Write tracking code for page-thank-you.php
  4. [x] Test with GA4 DebugView (verified events firing in dataLayer on production)
  5. [x] Mark conversions in GA4 Admin (pledge_form_submit marked as key event with $1 value)
  6. [ ] Build funnel exploration report