بروزرسانی: 27 خرداد 1404
How to A/B Test for Free with Google Tag Manager, and Any Marketing Analytics Tool.
Next add an allowed cookie for _gtm_exp or whatever identifier you’d like to build for your GTM experimentation.\xa0
Create a GTM Experiment Tag
\xa0\xa0\xa0\xa0var tagline = document.querySelector(‘.hero-tagline’);
You can also just build a cookie using custom HTML, but why work harder than you have to? Once you have imported it into your templates and accepted permissions, you can start building multiple cookies with ease.\xa0
You did it! You made it! You created a fully functioning A/B test machine in GTM with FREEEEE tools. But yeah that was a lot of work. You may want to pay for something to avoid the long and drawn out (but cool) process above. But if you don’t and you end up using this solution…maybe you can pay me instead 🙂\xa0
If you already have a conversion that you want to use with this setup you can skip this section. Otherwise, if you want to set up a secondary conversion or you have no conversion you can follow along with the below to set up one.\xa0
For the trigger we want it to fire on all pageview events where the cookie does not yet have a value that includes our test.\xa0
For this example, we’ll be updating the text of the hero tagline by using a Custom HTML tag.\xa0
Now that we have our conversion, let’s navigate to custom dimensions. Let’s create both a User\xa0 based custom dimension for our cta_button_audience which is handling our cookie value.\xa0
\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0tagline.innerHTML = ‘Build Sustainable Growth <i class=”far fa-arrow-right” aria-hidden=”true”></i>’;
BONUS: if you integrate GA4 with Microsoft Clarity you can also pull in your GA4 segments (audiences), making this a breeze to analyze! I still like having the filters but it can help streamline the process.\xa0
First lets build a Cookie in GTM by importing the template “Cookie Creator” from the Community Gallery. Review the permissions (which allow cookies to be written if you specify them in the template) of this Tag Template and select “Add to Workspace.”
In GA4, there are a few steps we need to take to get this to work. First, we need to set up our conversions. Some may already be set up, but the one we just built above we need to set as a conversion. You can either wait for the event to show up in GA4 and then check the little blue toggle next to the event, or we can navigate to conversions and input the name of the event manually. Let’s do that one.\xa0
Set Up Your Custom Dimension in your Marketing Analytics Tool
Now that we have our RegEx table, we can use it to build the functionality of our split test. We’ll be using the 0-49 randomized number to set the control & 50-99 to set the variant.\xa0
The death of Google Optimize is upon us. And wowee, aren’t you a little bit heartbroken. Gone are the days where you’ll be able to switch a button on your website from red to green and run a mindless A/B test. Now you have to pay $60,000 annually for that. But wait! What if I told you that you can continue to run A/B testing FOR FREE, leveraging tools that are probably already on your website. Would you pay me $60,000? How about $2? I’ll take it…
Usually, our main conversion would be a form submit or purchase, but we are going to use cta\xa0 clicks for this example.
Now is probably the most challenging part. You are going to need to know a bit of JavaScript but if you don’t, ChatGPT is a great resource. Just ask it to help you target and change the element you want to change. Unfortunately, GTM is not equipped with a visual editor like Google Optimize to help you change. If you wish you can use a chrome extension such as “visual css editor” which has a lot of the same functionality as a CRO visual editor and even helps you export code. Overall, you will probably hit a snag at some point and need some help from either AI or a JavaScript developer. Regardless, I used ChatGPT for this change and if it’s good enough for me, it’s good enough for you!\xa0
Now we can filter by both our key action that we want to see and also the different variations. This gives us ultimate clarity (pun intended) into how the different pages are performing with our variations! Give it a few days and you’ll get your changes in two different heatmaps!\xa0