'
// gtag basic snippet code do not change
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
// the gtag config function to configure the measurement/property ID on the gtag tracker with other avilable settings i.e cookieDomain auto that sets the _ga cookie on the Top Level Domain of the page.
// the configuration function sends a default pageview hit to Google Analytics Meaurement/Property ID i.e UA-XXXXXXXXX-X.
gtag('config', 'UA-116473955-1', {
'cookie_domain': 'auto',
});
window.addEventListener('pushstate', function (e) {
// the gtag config function to re-configure the measurement/property ID on the gtag tracker with other available settings i.e cookieDomain auto that sets the _ga cookie on the Top Level Domain of the page.
// the configuration constructor sends a default pageview hit with the SPA journey change pageview to Google Analytics Meaurement/Property ID i.e UA-XXXXXXXXX-X.
gtag('config', 'UA-116473955-1', {
'cookie_domain': 'auto',
'page_location': e.target.document.URL// to send the pageview with the new SPA changed URL
});
}, false);
window.addEventListener('beforeunload', function (e) {
if (window.performance) {
// A Performance object offers access to the performance and timing-related information
// The Math.round() function call to returns the value of a number rounded to the nearest integer.
var timeSincePageLoad = Math.round(performance.now());
// gtag function call to send event hit to Google Analytics along with the variables
gtag('event', 'timing_complete', {
'name': 'load',
'value': timeSincePageLoad,
'event_category': window.document.title
});
}
});