mirror of
https://github.com/ipfs/awesome-ipfs.git
synced 2024-12-27 08:19:25 -05:00
chore: add google analytics
This commit is contained in:
commit
229e0bd853
@ -2,8 +2,8 @@
|
||||
<html lang="{{ .Site.LanguageCode }}">
|
||||
<head>
|
||||
{{ partial "head" . }}
|
||||
{{ partial "analytics" . }}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="charcoal sans-serif w-90 mw8 center">
|
||||
<nav class="mh2 montserrat mv4 fw6 flex-wrap ttu tracked sans-serif flex flex-between">
|
||||
|
70
src/layouts/partials/analytics.html
Normal file
70
src/layouts/partials/analytics.html
Normal file
@ -0,0 +1,70 @@
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
// https://github.com/schalkneethling/dnt-helper/blob/master/js/dnt-helper.js
|
||||
function _dntEnabled(dnt, userAgent) {
|
||||
"use strict";
|
||||
var dntStatus =
|
||||
dnt ||
|
||||
navigator.doNotTrack ||
|
||||
window.doNotTrack ||
|
||||
navigator.msDoNotTrack;
|
||||
var ua = userAgent || navigator.userAgent;
|
||||
var anomalousWinVersions = [
|
||||
"Windows NT 6.1",
|
||||
"Windows NT 6.2",
|
||||
"Windows NT 6.3"
|
||||
];
|
||||
var fxMatch = ua.match(/Firefox\/(\d+)/);
|
||||
var ieRegEx = /MSIE|Trident/i;
|
||||
var isIE = ieRegEx.test(ua);
|
||||
var platform = ua.match(/Windows.+?(?=;)/g);
|
||||
if (isIE && typeof Array.prototype.indexOf !== "function") {
|
||||
return false;
|
||||
} else if (fxMatch && parseInt(fxMatch[1], 10) < 32) {
|
||||
dntStatus = "Unspecified";
|
||||
} else if (
|
||||
isIE &&
|
||||
platform &&
|
||||
anomalousWinVersions.indexOf(platform.toString()) !== -1
|
||||
) {
|
||||
dntStatus = "Unspecified";
|
||||
} else {
|
||||
dntStatus =
|
||||
{ "0": "Disabled", "1": "Enabled" }[dntStatus] || "Unspecified";
|
||||
}
|
||||
return dntStatus === "Enabled";
|
||||
}
|
||||
|
||||
(function() {
|
||||
if (!_dntEnabled() && location.hostname !== "localhost") {
|
||||
!(function(n, o, d, e, j, s) {
|
||||
n.GoogleAnalyticsObject = d;
|
||||
n[d] ||
|
||||
(n[d] = function() {
|
||||
(n[d].q = n[d].q || []).push(arguments);
|
||||
});
|
||||
n[d].l = +new Date();
|
||||
j = o.createElement(e);
|
||||
s = o.getElementsByTagName(e)[0];
|
||||
j.async = 1;
|
||||
j.src = "//www.google-analytics.com/analytics.js";
|
||||
s.parentNode.insertBefore(j, s);
|
||||
})(window, document, "ga", "script");
|
||||
if (!ga) return;
|
||||
ga("create", "UA-96910779-8", "auto");
|
||||
ga("send", "pageview");
|
||||
|
||||
// track outbound project clicks
|
||||
document.addEventListener(
|
||||
"click",
|
||||
function(e) {
|
||||
var href = e.target.closest("a") && e.target.closest("a").href;
|
||||
if (href && href.indexOf("http") > -1) {
|
||||
ga("send", "event", "outbound", "click", href);
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
})();
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user