Analytics snippets

How to Send Custom GA4 Events from an A/B Test

★★★ Technical level 3 of 3

Written by Neil Webley · Last updated

Create and test GA4 custom events with consistent names, useful parameters and FreeCROTool A/B test attribution.

Quick answer

Use a GA4 recommended event when one accurately describes the action; otherwise create a consistently named custom event with only the parameters needed for analysis. Fire it at the moment the behaviour occurs, test it in DebugView, and mark it as a Key event only when it represents a meaningful outcome.

Should I use a recommended or custom GA4 event?

Check GA4's automatically collected and recommended events first. Names such as generate_lead, sign_up, login, search and ecommerce events have prescribed meanings and parameters that can populate existing reports and future integrations.

Create a custom event when no recommended event describes the behaviour. Examples might include completing a quote calculator, expanding delivery information or reaching an eligibility result. Do not invent a new purchase or signup name simply to label an experiment; keep the standard business event and attach experiment context separately.

How to name custom GA4 events

  • Start with a letter and use letters, numbers and underscores.
  • Do not use spaces or reserved prefixes such as ga_, google_ or firebase_.
  • Remember names are case-sensitive.
  • Use a verb-led description such as quote_completed.
  • Keep one stable definition across pages and experiments.
  • Do not put variant names into the event name; that fragments reporting.

Send a custom event with gtag.js

gtag('event', 'quote_completed', {
  quote_type: 'home_insurance',
  completion_method: 'guided_form'
});

Place the call after the Google tag is available and inside the callback that confirms the action. Do not fire it when the button merely appears.

Send the event with Google Tag Manager

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'quote_complete',
  quote_type: 'home_insurance',
  completion_method: 'guided_form'
});
  1. Create Data Layer Variables for the parameters.
  2. Create a Custom Event trigger named quote_complete.
  3. Create a GA4 Event tag named quote_completed.
  4. Map the variables and attach the trigger.
  5. Test in GTM Preview and GA4 DebugView before publishing.

How GA4 event parameters become report data

Parameters add context to an event. Use categorical strings for attributes such as form type and numerical values for quantities. Do not send names, email addresses, phone numbers or other personal information.

Seeing a parameter in DebugView does not automatically make it available as a standard report dimension. Register appropriate custom dimensions or metrics in GA4 when the value needs to be analysed, then allow for processing time. Avoid high-cardinality values such as timestamps or unique IDs unless the implementation genuinely requires them.

Design events for an A/B test

Define the event before launch and keep it identical for control and variants. A variant-specific name makes comparison harder and can hide instrumentation differences. Separate the primary business outcome from diagnostic behaviours:

RoleExampleUse
Primary outcomegenerate_leadJudge whether the test achieved its goal.
Secondary outcomequote_startedUnderstand progress through the funnel.
Diagnostic interactiondelivery_help_openedExplain how visitors used the changed interface.

Mark an event as a GA4 Key event only if it is important to the business. Turning every click into a Key event makes reports noisy and does not make the experiment more successful.

Send a custom event from FreeCROTool

cro_tests.fireEvent('signup', {
  name: 'newsletter_signup_completed',
  signup_location: 'footer'
});

FreeCROTool publishes this as freecro_signup and adds the current test ID, variant and status. The name parameter becomes the readable action label in FreeCROTool reporting. Use a lowercase type and a stable name.

Calls in the hand-coded test editor receive the test ID automatically when published. A call from the project's shared main-tag initialisation script must pass the actual test ID:

window.cro_tests.fireEvent(1234567890123, 'signup', {
  name: 'newsletter_signup_completed'
});

Use the named wrappers for clicks, pages and purchases when they fit. See all event helpers, click tracking, and purchase revenue tracking.

Test and maintain the event

  • Trigger it once in control and every variant.
  • Confirm it does not fire on load, refresh or failed completion.
  • Inspect its name and parameters in DebugView.
  • Test consent accepted and rejected.
  • Document ownership and meaning before launch.
  • Do not rename it during the experiment.

Refer to Google's current recommended events, event naming rules and event parameter guidance.

© 2026 FreeCROTool. All rights reserved | FAQ | site map | Terms and conditions