|
// a helper function |
|
var getParameter = function(param) { |
|
var codedParams = (new RegExp(param + '=([^&]+)')).exec(window.location.search); |
|
if (codedParams != null) { |
|
return decodeURIComponent(codedParams[1]); |
|
} |
|
return ''; |
|
}; |
|
|
|
// Measure with Google Analytics |
|
var analytics = function() { |
|
|
|
// Vanilla Google Analytics script |
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
|
|
|
// Collect the data |
|
var contextPath = getParameter('xdm_e') + getParameter('cp'); |
|
var userKey = getParameter("user_key"); |
|
var timezone = getParameter("tz"); |
|
var loc = getParameter("loc"); |
|
var license = getParameter("lic"); |
|
var cv = getParameter("cv"); |
|
|
|
// Send the data to Google Analytics |
|
ga('create', 'UA-XXXXX-YY', 'auto'); |
|
|
|
// Add into custom dimensions |
|
ga('set', 'dimension1', contextPath); // Cloud Server Base URL |
|
ga('set', 'dimension2', userKey); // User Key |
|
ga('set', 'dimension3', timezone); // Timezone |
|
ga('set', 'dimension4', loc); // Location |
|
ga('set', 'dimension5', license); // License |
|
ga('set', 'dimension6', cv); // CV |
|
ga('set', 'dimension7', 'Add-On / Macro Name Here'); // Add-On Name |
|
|
|
ga('send', 'pageview'); |
|
}; |
|
|
|
analytics(); |