A/B Test and Google Analytics Integration

Crazy Egg can optionally send a custom event to Google Analytics whenever an A/B Test variant is viewed by one of your site visitors. This event will include custom properties specifying the name and ID of the variant that was viewed and the name and ID of the associated A/B Test for use in your Google Analytics reports.

Integration method 

If you have installed Google Analytics (GA4) directly on your site this installation method is for you.  

GTM: If you installed Google Analytics through Google Tag Manager, you must follow some extra steps so Crazy Egg’s script can send custom events to Google Analytics.  See A/B Test and Google Analytics Integration via GTM

Configuring Custom Definitions in Google Analytics

You will need to configure Google Analytics to report on the custom event properties that Crazy Egg sends. Otherwise, they will not consistently appear in your GA reports. These steps are repetitive, but they only have to be performed once to integrate Crazy Egg fully with Google Analytics.

Log in to Google Analytics at https://analytics.google.com/ and select the desired account and property.

Click Admin from the bottom of the navigation area on the left side of the page.

Under Data Display, select Custom Definitions.

Click the Create custom dimension button.

Create the “Crazy Egg AB Test ID” dimension

  • Enter Crazy Egg AB Test ID into the Dimension name field
  • Enter crazyegg_ab_test_idinto the Event parameter field
  • Click Save

Create the “Crazy Egg AB Test Name” dimension

  • Enter Crazy Egg AB Test Name into the Dimension name field
  • Enter crazyegg_ab_test_nameinto the Event parameter field
  • Click Save

Create the “Crazy Egg Variant ID” dimension

  • Enter Crazy Egg Variant ID into the Dimension name field
  • Enter crazyegg_variant_idinto the Event parameter field
  • Click Save

Create the “Crazy Egg Variant Name” dimension

  • Enter Crazy Egg Variant Name into the Dimension name field
  • Enter crazyegg_variant_nameinto the Event parameter field
  • Click Save

Create the “Crazy Egg AB Test and Variant” dimension

  • Enter Crazy Egg AB Test and Variant into the Dimension name field
  • Enter crazyegg_ab_test_and_variant into the Event parameter field
  • Click Save

Afterward, the Custom dimensions table should have four new custom dimensions:

Dimension nameDescriptionEvent
Crazy Egg AB Test IDCrazy Egg A/B Test IDcrazyegg_ab_test_id
Crazy Egg AB Test NameCrazy Egg A/B Test Namecrazyegg_ab_test_name
Crazy Egg Variant IDCrazy Egg Variant IDcrazyegg_variant_id
Crazy Egg AB Test and VariantCrazy Egg A/B Test and Variantcrazyegg_ab_test_and_variant
Crazy Egg Variant NameCrazy Egg Variant Namecrazyegg_variant_name

Confirming your integration

You’ll need to visit the webpage you have the A/B test setup on in order to see data.  

Log in to Google  at https://analytics.google.com/ and select the desired account and property.

Click View realtime →

Scroll down to the Event count by Event name section.

Whenever a visitor views an A/B Test, a crazyegg_variant_view event should appear in this section.

Clicking the crazyegg_variant_view event name will show the event counts for the event properties defined earlier: crazyegg_ab_test_idcrazyegg_variant_id , etc.

Was this article helpful?

Related Articles

Need Support?

Can’t find the answer you’re looking for? Don’t worry we’re here to help!

Submit a request