plausible-exclusion.html 1.83 KB
Newer Older
Jackson Chen's avatar
Jackson Chen committed
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
41
42
43
44
45
---
layout: default
title: plausible analytics exclusion
---
<div>
	<h1>Plausible Exclude</h1>
    <p>NOTE: JavaScript is required to disable tracking, but tracking requires JavaScript anyways. Don't bother if you disable JavaScript here (or not on jacksonchen666.com).</p>
	<div>Click the button below to toggle your exclusion in analytics for this
		site</div>
	<div>You currently <span id="plausible_not">are not</span><span id="plausible_yes">are</span>
		excluding your visits.</div>
	<a id="plausible_button" href="javascript:toggleExclusion()">Exclude my visits</a>
</div>

<script>
	window.addEventListener('load', function (e) {
		var exclusionState = window.localStorage.plausible_ignore == "true"

		if (exclusionState) {
			document.getElementById("plausible_not").style.display = "none"
			document.getElementById("plausible_yes").style.display = "inline"
			document.getElementById("plausible_button").innerHTML = 'Stop excluding my visits'
		} else {
			document.getElementById("plausible_yes").style.display = "none"
			document.getElementById("plausible_not").style.display = "inline"
			document.getElementById("plausible_button").innerHTML = 'Exclude my visits'
		}
	});

	function toggleExclusion(e) {
		var exclusionState = window.localStorage.plausible_ignore == "true"

		if (exclusionState) {
			delete window.localStorage.plausible_ignore
			document.getElementById("plausible_yes").style.display = "none"
			document.getElementById("plausible_not").style.display = "inline"
			document.getElementById("plausible_button").innerHTML = 'Exclude my visits'
		} else {
			window.localStorage.plausible_ignore = "true"
			document.getElementById("plausible_not").style.display = "none"
			document.getElementById("plausible_yes").style.display = "inline"
			document.getElementById("plausible_button").innerHTML = 'Stop excluding my visits'
		}
	}
</script>