-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathanalytics.js
27 lines (20 loc) · 1018 Bytes
/
analytics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*This function will load script and call the callback once the script has loaded*/
function loadScriptAsync(scriptSrc, callback) {
if (typeof callback !== 'function') {
throw new Error('Not a valid callback for async script load');
}
var script = document.createElement('script');
script.onload = callback;
script.src = scriptSrc;
document.head.appendChild(script); }
/* This is the part where you call the above defined function and "calls back" your code which gets executed after the script has loaded */
// loadScriptAsync('https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX', function () {
// window.dataLayer = window.dataLayer || [];
// function gtag() { dataLayer.push(arguments); }
// gtag('js', new Date());
// gtag('config', 'G-XXXXXXXXXX', { 'anonymize_ip': true });
// })
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-125339405-1', 'auto');
ga('send', 'pageview');
loadScriptAsync(src='https://www.google-analytics.com/analytics.js')