How to setup Google Optimize server side test with GTM
Recently I come across A/B testing, to see which algorithm is most effective to trigger user clicks.
I assume you have Google Analytics ready. Let’s create an experiment, and select the type A/B test.
Create a variant, put in whatever name you like. Then set Page Targeting to
SERVER_SIDE. Link up with GA & set the objective
Create 2 variables: experiment ID & variant
- Check the option Enable overriding settings in this tag
- Add 2 variables to Fields to Set
- Set the trigger to All Page
The fields to set is allow you to define which experiment & which variant to run.
In server side (I use PHP here), randomly choose a variant, and select the algorithm to use
In front end, trigger the experiment manually, by setting the
Note that the
dataLayer.push must before the GTM script.
If you have any questions, please ask here.
P/S: If you’re looking for other way of do A/B testing, this article might be for you
Flexible A/B Testing with AWS Lambda@Edge