server-sidegtag.jsgoogle-optimize

Gtag.js optmize server_side implementation not working


I need some help with a server side implementation of optimize with gtag.js (the new global tag from Google).

With analytics.js it was as simple as ga('set', 'exp', 'experimentid.0'); The manual can be found here

With gtag.js set should work like this:gtag('set', {'exp': 'experimentid.0'});, but the values are not picked up by Google Optimize/Analytics. I tried putting it before the config tag and in the config tag as additional config information. gtag('config', '<target_ID>', {<additional_config_info>});

Furthermore i also tried changing exp in expId (like in an example on this page) To no avail.

Does someone have a working server_side optimize code or can help me out?


Solution

  • I've had a response from the Google Optimise team: gtag.js does not yet support setting the experiment parameters you might be familiar with from the measurement protocol. We're looking into adding support. So it looks like the only way at the moment is to revert to analytics.js