I'm using Google Optimize for creating A/B tests. I'm using it in server side mode as in this guide: https://developers.google.com/optimize/devguides/experiments
That guide shows an easy way of setting which experiment is running with which variant by rendering the JS code on the server which sets the experiment id and variant id:
// 2. Create a tracker.
ga('create', 'UA-XXXXX-Y', 'auto');
<?php
<<<HTML
// 3. Set the experiment ID and variation ID.
ga('set', 'exp', '$experimentId.$variationId');
HTML;
?>
// 4. Send a pageview hit to Google Analytics.
ga('send', 'pageview');
However I'm using Google Tag manager and so far haven't managed to find any guide that shows how to set variables from the server with it. ga
is an undefined variable so the above doesn't work.