5.6K members online now
5.6K members online now
Everything you need to know about setting up Optimize including creating your account and container, linking to Google Analytics and how to tag your site.
Guide Me

Server side experiment using Google Tag Manager

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭



I've implemented my experiment on our own server (as we had to keep the url the same for commercial reasons). Our server decides between experiment 0 and 1 and inform Google via the data layer as follows:




  googleOptimizeExperimentId: '[experimentIdHere]', 
googleOptimizeExperimentVariation: '1', event: 'optimiseExperimentLoad' });



Then in our Tag Manager config, we have the following under "More settings' on the Google Optimize tag.



Fields to  Set Field Name Value

expId  {{googleOptimizeExperimentId}}

expVar {{googleOptimizeExperimentVariation}}

Those variables reference variables we've set up to look at the data layer.


We're not getting anyone on variation 1 of the checkout despite visiting it ourselves.


Anyone have any ideas what may cause this?

1 Expert replyverified_user

Server side experiment using Google Tag Manager

Google Employee
# 2
Google Employee



Are you interested in using any of the targeting functionality of Optimize (i.e. geo targeting etc)?


It sounds not since you probably make the full decision and decide to show the variants on the server side.


If this is the case, you don't really need to use the Optimize tag - you need to do the configuration on the GA side:


ga('set', 'exp', '$experimentId.$variationId');


See: Optimize Server-side Experiments


Server side experiment using Google Tag Manager

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

i tried using both ga and gtm setup for server side experiments but none seems to work. 


i'm doing an A/B test and set in :

ga -> ga('set','exp','hereismyid',1)

gtm -> expId (field) {{experimentid}} (value), expVar (field) {{experimentVar}} (value)


is there any wrong implementation in here?



the value of experimentId and experimentVar is already being passed as i show it in console.


Can you help me ASAP? thankyou very much

Server side experiment using Google Tag Manager

Google Employee
# 4
Google Employee



Are you adding the Optimize plugin in your page right? Just to explain things a little bit more:


You have 2 options at the moment with Optimize


a) Use one of the 2 Optimize implementation methods (DOM changes with A/B & MT or redirect) for your experiments. In that case you should install the Optimize plugin in your pages and this is the script that will apply those implementations.


b) Provide your own implementation and use just the GA api to report your experiment hits. Here you are mostly using plain GA. Optimize is not involved at all at your pages and is only used for reporting & statistical engine (to determine leaders). In that case, you should not install the Optimize plugin in your pages.


Its not possible at the moment to use the Optimize implementation (i.e. the editor) and control it with that API (i.e. pick yourself which variant to show). So server side means no editor & no Optimize plugin or GTM installation.


You should create an experiment with correct variants in Optimize, in order to retrieve your experiment ID when you start it (you need to pass this in the API) and have correct reporting, but other features like weights and targeting will also not apply - you are supposed to implement those too.


If there was no misunderstanding and you still have problems could you provide your container ID or URL of your page?