How do I measure time spent on each variant?

  • 24 August 2012
  • 5 replies
  • 2 views

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


5 replies

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.

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

“”

Userlevel 3

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.

Thank you Johny,

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

Reply