forked from yamadatomonori/Critical-CSS-Extractor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathga.js
More file actions
37 lines (30 loc) · 1.16 KB
/
ga.js
File metadata and controls
37 lines (30 loc) · 1.16 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
var script = document.createElement('script');
script.setAttribute('async', '1');
script.setAttribute('src', 'https://www.google-analytics.com/analytics.js');
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(script, firstScript);
function executeGAMethods() {
window.ga = window.ga || function() {
(window.ga.q = window.ga.q || []).push(arguments);
};
window.ga.l = + new Date();
window.ga('create', 'UA-68451209-1', 'auto', {'name': 'ccss'});
window.ga('ccss.set', 'checkProtocolTask', function() {});
window.ga('ccss.send', 'pageview', location.href);
window.addEventListener('error', function(ev) {
window.ga('ccss.send', 'exception', {
'exDescription': ev.message,
'exFatal': false
});
}, false);
}
if (location.protocol == 'chrome-extension:') {
executeGAMethods();
} else {
var script = document.createElement('script');
script.appendChild(
document.createTextNode(
executeGAMethods.toString() + '\n' + executeGAMethods.name + '();'));
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(script, firstScript);
}