How do I measure time spent on each variant?


#1

Hi there,

I’m interested in knowing how much time users are spending on each variant I’ve created. I’ve enabled Google Analytics, but it looks like that’s only reporting on all the variants, since they all live at the same URL. Is there a way to get at time spent/time on page for each variant?

Thanks!

Yossi


#2

Yes, if you want to track each version separately you need to hack the tracking script a little bit.

You will see this line in your script:
_gaq.push([’_trackPageview’]);

For each page you want to track separately you will change it to look more like this:
_gaq.push([’_trackPageview’,’/your-landing-page/a’]);

I suggest giving it the same naming convention as the variant, that will make it easier to recognize.

So, if you are doing a classic A/B test you would do something like:

The Google Analytics script for Varient A includes:
_gaq.push([’_trackPageview’,’/your-landing-page/a’]);

The Google Analytics script for Varient B includes:
_gaq.push([’_trackPageview’,’/your-landing-page/b’]);

Now you will see different page statistics for each variant that you have marked in this way.


#3

How to do it with universal analytics?

Will this work?

ga(‘create’, ‘UA-xxxxxxx-x’, ‘mypage.com’);
ga(‘require’, ‘displayfeatures’);
ga(‘send’, ‘pageview’,’/your-landing-page/a’ );

Thanks


#4

“”


#5

Hey Luis!

Replace this line of code in your script

ga(‘send’, ‘pageview’ );

with this:

ga(‘send’, ‘pageview’, document.location.pathname + window.ub.page.variantId + window.location.search.replace(/+/g,’%20’));

That should correctly track each page variant independently in your reporting.


#6

Thank you Johny,

I will start tracking and check the results, for feedback.