4

When I am working on setting up Google Analytics Experiments in my page, I found the Original page and Variation page both need Experiments Code and Google Analytics code write inside them.

During the Setting up, I found that the Experiments need us to have Google Analytics Code and Google Experiment Code inside the page. Like Below:

enter image description here

Here is the Question:

My Google Analytics is set up via Google Tag Manager(Google Tag Manager has a good user interface to let me form all my GA account and Custome Dimension). So I don't need write any GA code in the test page. And I know Google Experiments can't run in Google Tag Manager.

There is no GA code existing in my test page because GTM already does that.

How can I set up Experiments if my GA is set up in GTM?

or

Google Experiments only can work in the page which has GA code inside?

donggaolao
  • 43
  • 6
  • Haven't tested it yet, but you could probably use the Experiment Javascript API to get the selected variation in a custom HTML Tag, feed it to a lookup table and display another custom HTML tag based on this. The "normal" experiments code will not work properly, since the redirect is executed only after the tag container is loaded (which happens asychronously, so most likely the original page will show up before the redirect). – Eike Pierstorff Sep 09 '15 at 17:28
  • possible duplicate of [How to run Google Experiment within Google Tag Manager](http://stackoverflow.com/questions/23575878/how-to-run-google-experiment-within-google-tag-manager) – nyuen Sep 09 '15 at 18:11
  • Hi Eike, thank you for answering my question! But I still don't understand what is the meaning of get the selected variation in a custom HTML tag. Do you mean I need to put the whole variation page to a custom HTML Tag? – donggaolao Sep 09 '15 at 20:23
  • This is more or less what I mean - doing redirects via GTM doesn't work to well since the page has to be partially loaded before the redirect fires. If your page uses jQuery I would create the variations as static pages and do a custom tag that does a partial load to retrieve only the variation part (without head etc), i.e. something like: $( "#divwithvariations" ).load( "/variation.html #divwiththedifferentcontent" );. No guarantees that this will work perfectly, but it will certainly be better than doing redirects via GTM. – Eike Pierstorff Sep 10 '15 at 07:15

1 Answers1

0

Finally find a solution for testing Session Duration. (At least it works for me, so you can try it.)

Suppose your Google Analytics already set in your Google Tag Manager(New Version):

1) Firstly, you need to make sure the experiment script tag set immediately after the in your original page. My Setting is Session Duration, 100% of User Traffic

2) Don't care about the Experiments says Google Analytics Code not found in your two page, get your Experiments ID(Exp:123456789) for this test and save the Experiments.

3) Use private window to open the original page serval times, you will randomly see the original page and new page.

4) Then, after 4 hours (Yes, it is.), I finally get the data.

enter image description here

If you want to test some specific tag or element on your page, you need to set up Tags and Triggers in your Google Tag Manager as below:

1) First, confirm the Experiment script tag should be set immediately after tag.

2) Create a Trigger to detect your original page url, exp:Page URL contains myWebsite.com/experimentsTestPage

3) Create a Custome HTML Tag to run the Experiments Api, exp:

4) Create a Custome HTML Tag to configure the pageVariation and run it. Exp:

// Ask Google Analytics which variation to show the user. var chosenVariation = cxApi.chooseVariation(); console.log("here:" + chosenVariation); var pageVariations = []; pageVariations[chosenVariation]();

Set the trigger as the one you create above.

Then when you open the original page, you can randomly see the original page and variation page.

REF: https://developers.google.com/analytics/solutions/experiments-client-side

donggaolao
  • 43
  • 6