How do I measure time spent on each variant?


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?




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:

For each page you want to track separately you will change it to look more like this:

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:

The Google Analytics script for Varient B includes:

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’, ‘’);
ga(‘require’, ‘displayfeatures’);
ga(‘send’, ‘pageview’,’/your-landing-page/a’ );





Hey Luis!

Replace this line of code in your script

ga(‘send’, ‘pageview’ );

with this:

ga(‘send’, ‘pageview’, document.location.pathname + +,’%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.