Rich-text Reply

Optimizely and Google Tag Manager

Ranning 05-13-14

Optimizely and Google Tag Manager

[ Edited ]

We are almost finished with a Universal Analytics/ GTM upgrade and I'm having a problem with passing through the Custom Dimension using GTM.


We have manually added the project code to the site (not through GTM), how should we track the Custom Dimension to ensaure that it fires from GTM to our analytics account?


 Would I just use a normal pageview/ event tag and then fire the Custom Dimension as part of this?


Sorry if the question is a bit jumbled!!



Level 2

AdamA 05-13-14

Re: Optimizely and Google Tag Manager

[ Edited ]

Hi Richard,

If I understand your question correctly, you're trying to get Optimizely to pass data to UA while also using GTM.

For the UA part of the integration, you can follow the instructions in this article and you should have it set up correctly:

For the GTM part of the integration, here's what we've seen work:
1. In GTM, turn on the "Tracker Name" setting, but don't fill anything in the text box.
2. Then go to "Create New Rule" and create a rule called something like "All Pages after Optimizely"
3. Specify the following conditions:
URL matches Regex .*
Event equals optimizely_loaded

So your tag in GTM will look like:
<script src="//">&lt;/script>
{'event': 'optimizely_loaded'}

For more information on the Optimizely/GA/GTM integration, I recommend this description (written by one of our customers):

Please let us know how that works for you!

brian-tcr 05-15-14

Re: Optimizely and Google Tag Manager

Hi Guys,

I use Google Tag Manager quite a bit and in general recommend that clients don't deploy any A/B testing tags via GTM. Your optimizely tag may occasionally take some time to load and result in a sub-optimal experience for the customer. Googles official line has also been that GTM doesn't support A/B testing tags.

The main reason for this is that the GTM tag needs to go in the body to work reliably across browsers. Secondly GTM fires tags asynchronously and in random order (although you can use some tricks to try to force tag firing order). As a result it's possible that your optimizely tag won't load until a portion or all of your page has already loaded. It probably won't happen but it could. For that reason I recommend clients to not use GTM to load their optimizely tags.

AdamA 05-15-14

Re: Optimizely and Google Tag Manager

Brian -- that's a great point. If you can have Optimizely load in the head tag, outside of GTM, that's definitely a better approach. If you must load it in GTM, then my instructions above can help hook it up to GA.

Ranning 05-28-14

Re: Optimizely and Google Tag Manager

Hi guys, thanks for the replies I have implemented most of the solution - I found the following article by vertical nerve useful

I load the Optimziely project code through our code not GTM but it is not easy to understand how I should be firing the information from Optimizely (Project/ Variation name) into our GA account using GTM, though this may be due to my relative inexperience with Custom Dimensions over Custom Variables. It only seems to want one should I just pull through the Project & variation name into one Dimension?


Level 2
Amanda 10-02-14

Re: Optimizely and Google Tag Manager

Thanks for following up on this @Ranning . One of my colleagues, @Gary , also just posted a great re-cap of this. You should check it out here. If you have any follow-up questions, he's a great resource! 

sarahingle 10-24-14

Re: Optimizely and Google Tag Manager



Our team has followed all of the instructions to integrate Optimizely using Google Tag Manager. Our experiment appears to be running fine and the data is being captured within Optimizely's reporting tool. However, we can not get Optimizely data to appear in our custom dimension within Universal Analytics. We have followed all the instructions in current blogs, including checking the tracker option in GTM. We have also made a custom dimension specifically for the test and are setting it in the edit portion of the test. Is there anything else that we can try? What might we be doing incorrectly?





MalcolmX 02-05-15

Re: Optimizely and Google Tag Manager



I have Optimizely code outside of GTM. I have UA set up through GTM. I want to use GTM to create custom dimensions to integrate Optimizely test data with UA. That's what I understood the question to be but I don't think that was what was answered but then again what do I know.


Can you point me in the right direction or clarify?


Many thanks.

Level 1
Brian_Abad 02-05-15

Re: Optimizely and Google Tag Manager

Hey @MalcolmX ,


Thanks for your question!


If you are using GTM to install UA onto your webpage, you can follow the instructions within our knowledge base to guide you with set-up to integrate Optimizely with UA, which you can find here:


Please let me know if I misunderstood your question or if I can help with anything else!




Brian Abad
Manager, Technical Support
Customer Success