-
Notifications
You must be signed in to change notification settings - Fork 0
/
analytics.html
40 lines (40 loc) · 1.85 KB
/
analytics.html
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
38
39
40
{% if jekyll.environment != site.debug and site.analytics.enable != false %}<script type="text/javascript" charset="utf-8" data-src="analytics">
/* <!-- Only proceed with loading the Google Analytics Script if the Browser Do-Not-Track feature is NOT enabled --> */
if (!navigator.doNotTrack) {
var __f = false;
var __a = function() {
{%- if site.analytics.type == "gtag" -%}
(function(i,s,o,g){
var a=s.createElement(o),m=s.getElementsByTagName(o)[0];
a.async=1;a.src=g;
m.parentNode.insertBefore(a,m);
})(window,document,"script","https://www.googletagmanager.com/gtag/js?id={{ site.analytics.id }}");
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
gtag("config", "{{ site.analytics.id }}");
{%- else -%}
(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","https://www.google-analytics.com/analytics.js","ga");
ga("create", "{{ site.analytics.id }}", "auto");
ga("send", "pageview");
{%- endif -%}
__f = true;
};
if (window.addEventListener) {
{% if page.app %}
window.addEventListener("load", __a, false);
{% elsif site.analytics.scroll %}
window.addEventListener("scroll", function() {if ((document.documentElement.scrollTop != 0 && __f === false) || (document.body.scrollTop != 0 && __f === false)) __a();}, true);
{% else %}
window.addEventListener("load", __a, false);
{% endif %}
} else if (window.attachEvent) {
window.attachEvent("onload", __a);
} else {
window.onload = __a;
}
}
</script>{% endif %}