Setting up the A / B test on Google Analytics with Google Tag Manager

Modified on Tue, 4 Dec, 2018 at 2:06 PM

Sign in to Google Tag Manager.

You'll find the Google Analytics Tag in the list of account tags.



Edit the existing tag:



Add a new custom dimension





Then you have to edit the value of the new dimension. To do this, press "new variable".



In the window that appears, choose "Custom Javascript":




In the " Custom Javascript " box , copy the following code:


function () {
  var cookie = document.cookie;
  if (cookie.indexOf('fstrz=') !== -1) {
    return cookie.indexOf('fstrz=true') !== -1 ? 'yes' : 'no';
  }
  return 'untracked';
}



Then, after saving, you can finalize the creation of the custom variable as below:



Finally, all you have to do is save the tag update and then publish the tag.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article