GA4 Experiment Tracking Setup
ClickMint CRO Platform — Client Documentation
Overview
ClickMint's A/B testing system runs a lightweight script on your pages that determines which experiment variant a visitor sees, then records that assignment in Google Analytics 4 (GA4). Conversion events — purchases, sign-ups — are automatically attributed to the correct variant because GA4 carries the experiment assignment as a user property throughout the session.
For this to work, the ClickMint script needs to be able to call gtag() (GA4's standard tracking function). There are three ways to make that happen, depending on how your site is set up.
How ClickMint Tracking Works
When a visitor lands on a page running an experiment:
- The ClickMint script loads from
https://experiments.api.clickmint.com/{YOUR_ORG_ID}{page-path}. - It checks for an active experiment on that URL, selects a variant, and (if needed) redirects or modifies the page.
- It calls
gtag('set', 'user_properties', { experiment_id: '...' })to tag the visitor's GA4 session. - It fires a
cm_trackingevent with all experiment parameters for impression reporting. - Later in the session, when a
purchaseor other conversion event fires, GA4 automatically attaches the experiment assignment — ClickMint's backend reads this to attribute the conversion to the correct variant.
The only requirement: gtag() or a standard GA4 dataLayer must be accessible on the page when the ClickMint script runs. The three approaches below are different ways to guarantee that.
Which Setup Is Right for You?
| Approach 1 — Native | Approach 2 — GTM Custom HTML | Approach 3 — GTM Serverless | |
|---|---|---|---|
| Who it's for | Developers with code access | Marketing/analytics teams using GTM | Agencies or advanced GTM users with complex setups |
| Requires code deployment | Yes | No | No |
| Keeps existing GA4 adapter | N/A | No — must replace | Yes |
| Works with sGTM / Consent Mode v2 | Yes | Limited | Yes |
| Setup complexity | Low | Medium | High |
Not sure which to choose? Follow this path:
Can you edit your site's HTML/template files directly?
├── Yes → Approach 1: Native Installation
└── No (you use GTM)
└── Do you use server-side GTM (sGTM), Consent Mode v2, or have a complex
multi-destination GA4 setup you can't afford to break?
├── Yes → Approach 3: GTM Serverless Configuration
└── No → Approach 2: GTM Custom HTML Tags
Approach 1 — Native Installation
Best for: Developers who can edit theme files, app layouts, or page templates directly.
Both scripts are added to your site's source code — GA4 first, then the ClickMint script. No tag manager is involved.
→ Full setup guide: Native Installation
Covers: Shopify theme.liquid, Next.js / React App Router, WordPress, generic HTML.
Approach 2 — GTM Custom HTML Tags
Best for: Marketing or analytics teams who manage tags via GTM and don't need to touch code.
Both scripts are installed as Custom HTML tags in GTM. Your existing built-in GA4 adapter (GA4 Configuration tag, Google Tag) is replaced with a raw gtag.js Custom HTML tag to ensure the dataLayer is fully accessible.
→ Full setup guide: GTM Custom HTML Tags
Covers: core GTM setup, plus platform-specific notes for Microsoft Clarity, Segment, PostHog, Adobe Experience Platform, Tealium iQ, Shopify + GTM, Klaviyo, Triple Whale, and Elevar.
Approach 3 — GTM Serverless Configuration
Best for: Agencies or advanced GTM users with server-side GTM, multi-destination setups, or complex Consent Mode v2 configurations they cannot afford to break.
The ClickMint script is added as a Custom HTML tag in GTM. Your existing Google Tag (GA4 adapter) stays in place — you don't replace it. Instead, ClickMint events are dispatched through a dedicated GA4 Event tag that reads experiment parameters from Data Layer Variables. This keeps your existing GA4 configuration intact while giving ClickMint a clean, reliable path to send tracking events.
→ Full setup guide: GTM Serverless Configuration
Covers: full tag, trigger, and variable configuration; Data Layer Variable reference table; GTM JSON import template for one-click setup.
FAQ
Will I lose historical GA4 data?
No. You're keeping the same GA4 Measurement ID (G-XXXXXXXXXX). Only the delivery mechanism changes. All historical data in your GA4 property remains intact.
Will my existing GA4 events (e-commerce, custom events) still work?
Yes, for Approaches 1 and 3. For Approach 2, if your previous setup used a built-in GA4 adapter to fire e-commerce events (e.g., purchase, add_to_cart), verify those events are still firing after switching to Custom HTML. Use GTM Preview mode to confirm.
Do I need to register custom dimensions in GA4?
Yes — this is required for conversion attribution to work. After setup, go to GA4 Admin → Data Display → Custom Definitions and register all of the following.
Custom Event
Go to Admin → Data Display → Events → Create custom event and create one entry:
| Custom Event Name | Matching Condition |
|---|---|
cm_tracking | event_name equals cm_tracking |
Event-Scoped Custom Dimensions
In the Custom Definitions tab, create each of these with scope set to Event:
| Suggested Name | Parameter Name | Description |
|---|---|---|
| CM Event Type | event_type | Impression type: variant_loaded, control, error |
| CM Experiment ID | experiment_id | ClickMint tracking ID for the experiment |
| CM Experiment Mode | experiment_mode | production or preview |
| CM Outcome ID | outcome_id | The specific outcome/variant shown |
| CM Outcome Index | outcome_index | Numeric variant index |
| CM Outcome Type | outcome_type | redirect, repaint, control, or error message |
User-Scoped Custom Dimensions
Still in Custom Definitions, create each of these with scope set to User. These are what ClickMint uses for conversion attribution — they follow the visitor across the entire GA4 session.
| Suggested Name | User Property Name | Description |
|---|---|---|
| CM User Experiment ID | experiment_id | Links the visitor's session to an experiment |
| CM User Experiment Variant | experiment_variant | The variant token assigned to this visitor |
| CM User Outcome ID | outcome_id | The specific variant/outcome the visitor was assigned |
| CM User Outcome Index | outcome_index | Numeric variant index |
⚠️ Allow 24–48 hours after registering dimensions before conversion data appears in ClickMint reports. Impressions will show immediately; conversions require GA4's processing window.
Do I need to update my consent management setup?
If you use a Consent Management Platform (CMP — OneTrust, CookieBot, Shopify's built-in consent), ensure the new tags respect the same consent triggers. In GTM, use Consent Initialization - All Pages triggers and set analytics_storage as a required consent type.
I see "Data flowing" in GA4 — does that mean ClickMint is working?
Data flowing confirms GA4 is receiving events, but doesn't confirm the ClickMint assignment is being tracked. Check for the cm_tracking event in GA4's DebugView (Admin → DebugView) and verify it carries experiment_id and outcome_id parameters.
What if I'm on Shopify and can't edit theme code?
Use the GTM snippet instead. Most Shopify themes have a field for a GTM container ID in Theme Settings. Once GTM is loading, follow Approach 2 or Approach 3.
Getting Help
If you run into issues or need assistance:
- Email: [email protected]
- In-App Chat: Log in to your ClickMint dashboard and use the chat widget.
When contacting support, please include:
- Your GA4 Measurement ID (e.g.,
G-XXXXXXXXXX). - Which setup approach you used (Native, GTM Custom HTML, or GTM Serverless).
- A screenshot of the
cm_trackingevent in GA4 DebugView, or a browser console screenshot showingwindow.dataLayer. - The URL of the page you're testing.
Updated 10 minutes ago
