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
Crazy Egg sends its custom events to Google Analytics in one of two ways, depending on how you installed GA4 on your site. This article is for those who installed GA4 using Google Tag Manager.
Configure Google Tag Manager (GTM)
- Download the file Crazy Egg GA4 GTM integration.json
- Log in to GTM at https://tagmanager.google.com/.
- Select the desired site container from the Accounts tab.
- Click Admin from the navigation bar near the top of the page.
- Click Import Container
- Click Choose container file and select the previously downloaded file
Crazy Egg GA4 GTM integration.json
.
- Under Choose Workspace, click Default Workspace
- If there is not already a separate workspace, click the + button to add a new workspace, name it something like
Crazy Egg
, and then click Save. Otherwise, select your existingCrazy Egg
workspace.
- Under Choose an import option, click Merge.
- Select the Overwrite conflicting tags, triggers, and variables option.
- Click Confirm.
- Click Tags.
- Click the Crazy Egg Variant View tag.
- Ensure the Measurement ID is correct for the Google Analytics 4 tag installed on your site. Update the ID, if necessary, and click Save.
You should see this:If this is not what you see, go to troubleshooting GTM setup.
- Publish your changes by clicking the Submit button near the top-right corner of the page.
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_id
into the Event parameter field - Click Save
- Enter
- Create the "Crazy Egg AB Test Name" dimension
- Enter
Crazy Egg AB Test Name
into the Dimension name field - Enter
crazyegg_ab_test_name
into the Event parameter field - Click Save
- Enter
- Create the "Crazy Egg Variant ID" dimension
- Enter
Crazy Egg Variant ID
into the Dimension name field - Enter
crazyegg_variant_id
into the Event parameter field - Click Save
- Enter
- Create the "Crazy Egg Variant Name" dimension
- Enter
Crazy Egg Variant Name
into the Dimension name field - Enter
crazyegg_variant_name
into the Event parameter field - Click Save
- Enter
- 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
- Enter
Afterward, the Custom dimensions table should have four new custom dimensions:
Dimension name | Description | Event |
---|---|---|
Crazy Egg AB Test ID | Crazy Egg A/B Test ID | crazyegg_ab_test_id |
Crazy Egg AB Test Name | Crazy Egg A/B Test Name | crazyegg_ab_test_name |
Crazy Egg Variant ID | Crazy Egg Variant ID | crazyegg_variant_id |
Crazy Egg AB Test and Variant | Crazy Egg A/B Test and Variant | crazyegg_ab_test_and_variant |
Crazy Egg Variant Name |
Crazy Egg Variant Name | crazyegg_variant_name |
Confirming your integration
- Log in to Google Analytics 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_id
,crazyegg_variant_id
, etc.