Setting up Google Analytics 4 (GA4) on Unbounce MCP-managed pages requires a slightly different approach than pages built using the standard drag-and-drop builder.
Here is what you need to know to get GA4 working correctly on your MCP pages.
How GA4 Works on MCP Pages
As long as you have the Google Analytics integration enabled for your domain in Unbounce Script Manager, GA4 tracking will automatically run on your MCP pages.
What Works Automatically
Pageviews: Every page visit is tracked automatically, including A/B test variant pageviews.
Form Submissions: Forms created on MCP pages automatically fire the standard GA4 form submission events without any extra setup.
What Requires Manual Setup
Button, Link, and CTA Clicks: Because MCP pages use custom HTML elements rather than standard builder elements, click events will not fire automatically. If you want to track button or link clicks, you must add click-tracking code directly to your page.
Setting Up Click Tracking via AI Prompts
Since GA4 is already running on your domain to track pageviews and form submissions, do not ask your AI assistant to reinstall GA4, add the main gtag.js script, or include gtag('config') snippet calls.
Instead, ask your AI chat assistant (Claude, or ChatGPT) to add custom click-tracking attributes and script listeners directly to your page's HTML.
Core Instruction to Include in Your Prompts
When asking your AI assistant to set up click tracking, always include this base rule:
"GA4 is already installed on this page and page views + form submissions are already tracked. Do not add the gtag.js loader, a gtag('config', ...) call, or any GA snippet. Only add click event calls for links."
Copy-Paste Prompt Examples
Depending on your tracking needs, append one of these prompt variations to your AI chat session:
Basic CTA Tagging
"Add GA4 click tracking to every CTA button on this page. Use one delegated click listener plus data-ga-* attributes on the anchors — no inline onclick handlers."
Controlled Naming Conventions
"Tag the three pricing buttons. Fire event cta_click with params cta_id (starter/pro/enterprise), cta_location (pricing_table), and link_url. Use snake_case throughout, and don't invent params I didn't ask for."
Outbound Link Tracking
"Tag all outbound links with event outbound_click, sending link_url, link_text, and link_domain."
Phone & Email Links
"Tag the tel: and mailto: links with events phone_click and email_click, each including the destination as link_url."
Navigation Reliability (Prevent Dropped Events)
"For links that navigate in the same tab, make sure the event isn't dropped — use transport_type: 'beacon' or an event_callback, and do not preventDefault() and delay the navigation."
Avoid Double-Counting Outbound Clicks
"Enhanced Measurement outbound click tracking is already on. Only tag internal links and in-page anchors so outbound clicks aren't counted twice."
Targeted HTML Edits
"Here's the current page HTML. Add click tagging to the nav and footer links only. Leave all other markup byte-identical and show me a diff before applying."
Clean Code Separation
"Keep the data-ga-* attributes in the HTML and put the listener in a separate JS file I can pass as a js_ref, so I can restyle the page without touching tracking."
A/B Test Variant Parity
"Apply identical data-ga-* tagging to variants A and B of the Spring Promo page so the event data is comparable across the test."