Tuesday, August 16, 2016

Product list optimization project, part 1.1. Google Analytics tuning: Custom dimensions

First of all, there is a common approach to manage Google Analytics implementation - through Google Tag Manager. This method has many advantages, but discussion of those is beyond the scope of this series of posts. From now on I assume this approach by default.

There is a great article of Simo Ahava “Improve Data Collection With Four Custom Dimensions”. It’s about 4 parameters which aren’t among dimensions and metrics of Google Analytics API by default, but are crucial for many web-analytics tasks. I didn’t use User ID in this project, but Client ID, Session ID and Hit timestamp were very helpful.

For those of you who decided to implement these custom dimensions too, I want to warn you about the subtle mistake in the Hit timestamp setting. I’ve written detailed comment about this under Simo’s article.

So in brief, when you configure Custom JavaScript Variable, you can’t treat milliseconds as other parts of the time (Hour, Minute, Seconds), because it’s a three-digit variable. Otherwise, “0.089” becomes “0.89” and exceeds “0.123”, which leads to awkward results in data when some page events precede their predecessors.

To fix this, you should add another function and apply it to milliseconds:

var pad00 = function(num) {
var norm = Math.abs(Math.floor(num));
return (norm < 10 ? '00' : (norm < 100 ? '0' : '')) + norm;

No comments:

Post a Comment