-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdisable-ga.html
32 lines (30 loc) · 1.05 KB
/
disable-ga.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
<html>
<head>
<meta name="robots" content="noindex, nofollow" />
<script>
// Set to the same value as the web property used on the site
// Please remove my Analytics ID before taking your site to production if you are forking/cloning this site (otherwise you will mess my own analytics). PLEASE
var gaProperty = "G-3DJL735HV0";
// Disable tracking if the opt-out cookie exists.
var disableStr = "ga-disable-" + gaProperty;
if (document.cookie.indexOf(disableStr + "=true") > -1) {
window[disableStr] = true;
}
// Opt-out function
function gaOptout() {
document.cookie =
disableStr + "=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/";
window[disableStr] = true;
}
</script>
</head>
<body>
Don't do anything here unless instructed to by a dev (aka Pat).
<br />
<a
onclick="alert('Google Analytics Tracking is now deactivated');"
href="javascript:gaOptout()"
>Click here to opt-out of Google Analytics</a
>
</body>
</html>