💡 Web projects can be hard. Our solutions specialists can help!

Analytics for A/B test performance

Learn how to set up A/B test analytics tracking with Google Tag Manager and Google Analytics 4.

By CloudCannon

  • 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.

  1. Go to your Google Analytics Admin, Custom Dimensions, and Create custom dimension

    Screenshot of Google Analytics 4 button 'Create custom dimensions'
  2. Next step: Running reports in Google Analytics

     

Google Tag Manager (more complex)

  1. 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

      Screenshot of Google Analytics 4 button 'Create custom dimensions'
  2. Add a new Data Layer Variable in Google Tag Manager to store the event name ab_test_name

    Google Analytics screenshot showing the Data Layer Variable section
  3. Add a new Tag in Google Tag Manager to pass the custom event to Google Analytics

    Google Tag Manager screenshot
  4. Add a new Trigger in Google Tag Manager to only pass our custom event through our new tag.

    Google Tag Manager Trigger screenshot

     

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.

  1. 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

    Google Analytics 4 Variables section screenshot
  2. From here you can add additional metrics such as bounce rate or engagement rate into the values column to compare the test versions.

  3. Once you've confirmed your additional metrics, the top of your report should look something like this:
    Google Analytics 4 Custom test screenshot

    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

  1. A/B testing for static sites
  2. JavaScript based A/B testing
  3. Cloudflare Worker-based A/B testing
  4. Analytics for A/B test performance
  5. Discuss implementation with our team