Optimizely, GA & GTM – a beautiful marriage (a tidy integration)
If you put 10 technical people in a dark room and ask for a solution to a software problem, you’ll have 10 happy developers and 10 different solutions. This is fine, we celebrate heterogeneity and welcome diversity but not all technical solutions are equal in terms of quality.
Take the GA, GTM and Optimizely integration challenge for example. Ideally you’ll have a ‘light touch’ solution that is benign, set up once to work for all tests and degrades gracefully if there are no tests running. We want a fire and forget solution that won’t ruin your day.
The solution presented here satisfies these requirements and we want to share it with you.
The solution uses two tags. One to extract the test information from Optimizely and one to fire this data into GA via a non-interaction event. There’s one trigger and a couple of variables. The Optimizely test needs a little tweak but beyond that, there are very few moving parts.
Here’s a GTM container ready to import: GTM, GA, Optimizely Container
You’ll need to change the UA ID used in the event tag of course but otherwise, it’s usable right now!
One of the most important parts of this technique (after the GTM setup) is a slight change to the Optimizely test ONLY if you’re doing a redirect test.
The first change is to tell the test to target ALL pages – control AND variations:
Note that in the example above, the page that we’re testing is /example/test and the variation page we’re redirecting to is /example/test-b. So, the regular expression in the screenshot above targets both pages.
Now that the test has been configured to fire on all pages, the test script will be run on all pages. This means the redirect will be attempted when the user lands on a variation page. In order to ensure that the user will not be redirected to the test variation page infinitely, we make this minor tweak to the test script:
We’ll follow up on this article next week with a FULL technical description of the technique. It’s quite detailed so we didn’t want to post too much detail and make this post overly long.