Analytics for A/B test performance
Learn how to set up A/B test analytics tracking with Google Tag Manager and Google Analytics 4.
- If you have added the JavaScript to your Liquid template, this will push your A/B test variation data through to Google Analytics.
- Ensure event tracking or goals are set up in Google Analytics to measure the KPIs relevant to the A/B test.
- If you’re using Google Analytics standalone or Google Analytics via Google Tag Manager, the instructions are a little different.
Google Analytics 4
Add a Custom definition for ab_test_name
to query for reporting in Google Analytics.
Go to your Google Analytics Admin, Custom Dimensions, and Create custom dimension
Next step: Running reports in Google Analytics
Google Tag Manager (more complex)
Add a Custom definition for
ab_test_name
to query for reporting in Google Analytics.Go to your Google Analytics Admin, Custom Dimensions, and Create custom dimension
Add a new Data Layer Variable in Google Tag Manager to store the event name
ab_test_name
Add a new Tag in Google Tag Manager to pass the custom event to Google Analytics
Add a new Trigger in Google Tag Manager to only pass our custom event through our new tag.
Running reports in Google Analytics
With the data properly passed to Google Analytics 4 (GA4), we'll now be able to use our Custom Dimension in reporting. Head to the Explore tab in GA4 and create a new blank exploration.
Add our AB Testing Custom Dimension as a Column and you'll see the custom event data and measurements of page views on your AB tests
From here you can add additional metrics such as bounce rate or engagement rate into the values column to compare the test versions.
Once you've confirmed your additional metrics, the top of your report should look something like this:
You can add additional columns as needed. If your
ab_test_name
variable isn't passing into Google Analytics correctly, the(not set)
column will have all of your event counts.
Monitoring and analyzing results
- Monitor the A/B test in real-time or after a set period.
- Analyse the data in Google Analytics 4 to determine the performance of each variation.
Lessons in this Tutorial
A/B Testing for Static Websites
- A/B testing for static sites
- JavaScript based A/B testing
- Cloudflare Worker-based A/B testing
- Analytics for A/B test performance
- Discuss implementation with our team