Rich-text Reply

Optimizely Universal Analytics Integration using GTM template tags: Case of redirects

Amara 07-02-15

Optimizely Universal Analytics Integration using GTM template tags: Case of redirects

[ Edited ]
When your test involves a redirect,  the experiment will not be stored in the `activeExperiments` list because it's not URL targeted to the page your redirect to. In order to workaround this, here is a script that also includes code to return the variation information read from the cookie that is dropped on the targeted page before your visitor is redirected:
 
 
The code will essentially push all relevant experiment information to the data layer.
In GTM, you can simply create a macro that will send the information with the tracking call in a dimension. 
 
**Disclaimer: This code has been written by an optimizely engineer and has not been tested. Please modify according to your needs and have your IT team do a thorough QA before setting live. 
-----
Teja Shah
Technical Support Representative
Optimizely

AdamA 07-07-15
 

Re: Optimizely Universal Analytics Integration using GTM template tags: Case of redirects

Thanks @teja, this is a great solution for when you're trying to implement Optimizely and GTM using template tags, when you'll have redirect tests running!

Optimizely
mattkam 08-03-15
 

Re: Optimizely Universal Analytics Integration using GTM template tags: Case of redirects

This is great! Quick Q for @teja: Does this work in tandem with the existing recommended solution for sending Optimizely IDs to GA (via GTM macro and PV tag...)? Or is it a total replacement? Just want to make sure I have both redirect & non-redirect experiments covered, and not overwriting each other.

 

Also, do you need to modify this JS with your own dimension slot # or no?

 

Thanks,

-Matt

Level 1
moviepass 11-11-15
 

Re: Optimizely Universal Analytics Integration using GTM template tags: Case of redirects

Would love to see a reply to this @mattkam! Did you ever get an answer?

mattkam 11-12-15
 

Re: Optimizely Universal Analytics Integration using GTM template tags: Case of redirects

hi @moviepass -- Yes I did get a response and 1) it's a complete replacement for the "official" Universal Analytics integration, i.e. should work for both redirect and standard A/B tests.

On #2 -- I didn't have to modify the JS; just specified the custom dimension in Google Tag Manager.

**One word of caution, I am still seeing significant variances from time-to-time on the metrics reported by GA vs. the Optimizely reports... Support said it might be because I'm firing off a custom event tag rather than piggybacking on my core Universal Analytics page view tag... I'd recommend you do the latter.

This is my setup:

1) The core Optimizely JS snippet is hard-coded on my site in <head> section (as it's recommended to not deploy through GTM)

Then to enable this integration I did the following:

2) Add 1 custom HTML tag which includes the JS listed on JSFiddle in that community post I listed in this ticket; the trigger is "All Pages" (with a few exceptions where I don't need it)

3) Add 1 Universal Analytics custom event tag. Which fires a custom event (rather than a PV) triggered upon the 'optimizely' data layer event from the JS in my first tag... This is where the custom dimension is set.

3) Setup a custom report in GA grabbing the custom dimension and metrics like sessions, conversions, etc.

Level 1
moviepass 11-12-15
 

Re: Optimizely Universal Analytics Integration using GTM template tags: Case of redirects

This is a fantastically thorough response, @mattkam, thanks for that and the speed of the reply!!

 

Just to confirm, you'd recommend NOT going with the custom event tag fire that you have as your current set up? Wondering out of curiosity why you'd go that route if it causes reporting discrepancies. 

 

It sounds like as long as I follow the original directions (include the JSfiddle snippet as a variable, pass that as the value for the correct dimension slot index within the UA tag I already have in place), there shouldn't be anything to worry about.

 

Let me know if the above is (in)correct!

 

Thanks again Smiley Very Happy

Dave1 11-15-16
 

Re: Optimizely Universal Analytics Integration using GTM template tags: Case of redirects

Hi @mattkam, thanks for the thorough reply.

To be clear, what were your reasons for doing steps 2) and 3) over placing the JSFiddle into a variable like Optimizely originally suggested here - https://help.optimizely.com/Integrate_Other_Platforms/Implementing_Optimizely_with_Google_Tag_Manage...?

Could you provide more info on firing the UA custom event tag by the data layer event? Sounds like a great solution for integration with GA only working on pages that you are testing and testing.

Thanks again for sharing!


Level 1