Comparing Page Views Per Session Across Variations in Convert

Sometimes is required to track how many page sessions a variation registers. And using the goals provided on Convert Experiences are not ideal for this task. This is the reason that we recommend the method for tracking them.

Tracking page views might helpful for publishers, who want to know if changes produce more page views.

To do this, we are going to use Google Analytics to help us do it. Also, this method can be used to track any dimension set up in Google Analytics.

The only thing to note is that this page view tracking will be per session in GA and not per Convert visitor, which can be acceptable.

First, open the Administration section of your Google Analytics Account:

 

Then on the Property panel select Custom Definitions:

 

Create a new Custom Dimension:

 

Call it Pages Views per Session or whatever you want to call it and make it of Scope Session, and create it.



You can at this point enable your Google Analytics integration for which you need to generate a new dimension.

(function(window) {
//Set the dimension that you will be using to track pages per session
var dimensionNumber = '1';
//The name that the cookie will save as
var cookieName = 'pageCounter';
//The length of a session in minutes
var sessionLength = 30;

var docCookies = {
getItem: function (sKey) {
if (!sKey) { return null; }
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
},
setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
var sExpires = "";
if (vEnd) {
switch (vEnd.constructor) {
case Number:
sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
break;
case String:
sExpires = "; expires=" + vEnd;
break;
case Date:
sExpires = "; expires=" + vEnd.toUTCString();
break;
}
}
document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
return true;
}
};

var pageCount = docCookies.getItem(cookieName);
var updatedPageCount = pageCount ? (parseInt(pageCount) + 1).toString() : '1'; // Incrementing pagecount else setting 1 as this is first page view

docCookies.setItem(cookieName, updatedPageCount, sessionLength * 60,'/');

// Set the dimension in GA then send a blank event to record it.
window.ga('set', 'dimension' + dimensionNumber, updatedPageCount);
window.ga('send', 'event', {nonInteraction:true});
})(window)

This code will count the number of page views per user on your site and will set the Page Views per Session on GA to this number for each user. 

*** IMPORTANT CHANGE THIS ****

Once the experiment is tracking you need create a custom report in GA 

Now that your experiment is tracking in Google Analytics, you can run an analysis of the data by creating a custom report and using the FunnelEnvy pages per session t-test calculator. The Google Analytics report will provide us with the number of sessions for each page per session bucket for each variation. This is important because it allows us to get a distribution of pages per session rather than just an average. In order to do a statistical analysis of both variations, you will need to calculate this distribution. Our calculator takes a lot of the work out of this by calculating everything and placing it into the t-test calculator on evanmller.org.

In GA, go to the “Customization” tab in the navigation and click the “+ New Custom Report” button.

*********

(function(window) {
//Set the dimension that you will be using to track pages per session
var dimensionNumber = '1';
//The name that the cookie will save as
var cookieName = 'pageCounter';
//The length of a session in minutes
var sessionLength = 30;

var docCookies = {
getItem: function (sKey) {
if (!sKey) { return null; }
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
},
setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
var sExpires = "";
if (vEnd) {
switch (vEnd.constructor) {
case Number:
sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
break;
case String:
sExpires = "; expires=" + vEnd;
break;
case Date:
sExpires = "; expires=" + vEnd.toUTCString();
break;
}
}
document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
return true;
}
};

var pageCount = docCookies.getItem(cookieName);
var updatedPageCount = pageCount ? (parseInt(pageCount) + 1).toString() : '1'; // Incrementing pagecount else setting 1 as this is first page view

docCookies.setItem(cookieName, updatedPageCount, sessionLength * 60,'/');

// Set the dimension in GA then send a blank event to record it.
window.ga('set', 'dimension' + dimensionNumber, updatedPageCount);
window.ga('send', 'event', {nonInteraction:true});
})(window)



 

Select "Metric Group" > "Sessions" and under "Dimension Drilldowns" section add in our Custom Dimension which you have created and chosen to send data from your Convert Experiment.



After saving it, you will be taken to the report.

Then click on "Secondary dimension" and select the “Pages Per Session” dimension.


 

Then select to show all the rows in the lower right part of the report. And make sure all rows are selected.

 

Then Export all your records by selecting the Export option on the upper left superior part of the report and select CSV.


 

Now you can upload the data to this calculator.

 

After uploading the calculator will let you know which of the variations of your experiment is the Winner relating to Page View per Session