2020-01-15 23:20:03 +00:00
|
|
|
/* Millions - a non-tracking web counter/analytics */
|
|
|
|
(function(counterHost){
|
|
|
|
if (!window) return;
|
|
|
|
|
|
|
|
if ("doNotTrack" in navigator && navigator["doNotTrack"] === "1") return;
|
|
|
|
// inspired by:
|
2020-01-15 13:23:04 +00:00
|
|
|
// https://github.com/simpleanalytics/scripts/blob/master/src/default.js
|
|
|
|
// https://docs.simpleanalytics.com/what-we-collect
|
|
|
|
// https://docs.simpleanalytics.com/uniques
|
2020-01-15 23:20:03 +00:00
|
|
|
|
|
|
|
var getLocation = function(href) {
|
|
|
|
var match = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
|
|
return match && {
|
|
|
|
href: href,
|
|
|
|
protocol: match[1],
|
|
|
|
host: match[2],
|
|
|
|
hostname: match[3],
|
|
|
|
port: match[4],
|
|
|
|
pathname: match[5],
|
|
|
|
search: match[6],
|
|
|
|
hash: match[7]
|
|
|
|
} || { href: href };
|
2020-01-16 11:07:13 +00:00
|
|
|
};
|
2020-01-15 23:20:03 +00:00
|
|
|
var parseQuery = function(queryString) {
|
|
|
|
var query = {};
|
|
|
|
var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
|
|
|
|
for (var i = 0; i < pairs.length; i++) {
|
|
|
|
var pair = pairs[i].split('=');
|
|
|
|
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
|
|
|
|
}
|
|
|
|
return query;
|
2020-01-16 11:07:13 +00:00
|
|
|
};
|
2020-01-15 13:23:04 +00:00
|
|
|
|
2020-01-15 23:20:03 +00:00
|
|
|
var selfUrl = getLocation(document.location.href);
|
|
|
|
// commented out for now // if (selfUrl=='localhost') return;
|
|
|
|
var refUrl = getLocation(document.referrer);
|
|
|
|
|
|
|
|
var bonzUrl = selfUrl.protocol + '//' + counterHost + '/one.php?for=' + selfUrl.hostname + '&path=' + encodeURIComponent(selfUrl.pathname) + '&width=' + window.innerWidth;
|
|
|
|
|
|
|
|
if (refUrl.href=='' || (refUrl.hostname && selfUrl.hostname != refUrl.hostname)) {
|
|
|
|
bonzUrl += '&unique=1';
|
|
|
|
}
|
|
|
|
|
|
|
|
var Q = parseQuery(selfUrl.search);
|
|
|
|
|
|
|
|
if (Q.utm_source || Q.ref || Q.pk_campaign) {
|
|
|
|
bonzUrl += '&ref=' + encodeURIComponent(Q.utm_source || Q.ref || Q.pk_campaign);
|
|
|
|
} else if (Q.fbclid) {
|
2020-01-16 11:07:13 +00:00
|
|
|
bonzUrl += '&ref=facebook.com';
|
2020-01-15 23:20:03 +00:00
|
|
|
} else if (refUrl.hostname && selfUrl.hostname != refUrl.hostname) {
|
|
|
|
bonzUrl += '&ref=' + encodeURIComponent(refUrl.hostname + refUrl.pathname);
|
|
|
|
}
|
|
|
|
|
|
|
|
var req = new XMLHttpRequest();
|
|
|
|
req.open("GET", bonzUrl, true);
|
|
|
|
req.send(null);
|
|
|
|
// we don't care about response yet
|
2020-01-15 13:23:04 +00:00
|
|
|
})('localhost');
|