PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / trunk
Matomo Analytics – Powerful, Privacy-First Insights for WordPress vtrunk
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / assets / js / optout.js
matomo / assets / js Last commit date
blocks 4 years ago admin.js 2 weeks ago asset_manager_core_js.js 6 days ago iframeResizer.contentWindow.min.js 2 years ago iframeResizer.min.js 2 years ago marketplace_setup_wizard.js 1 month ago optout.js 1 year ago settings.js 1 year ago
optout.js
106 lines
1 (function () {
2 var cookiename = 'mtm_consent_removed';
3
4 function listen_event(e, type, callback) {
5 if (e.addEventListener) {
6 return e.addEventListener(type, callback, false);
7 }
8
9 if (e.attachEvent) {
10 return e.attachEvent('on' + type, callback);
11 }
12
13 e['on' + type] = callback;
14 }
15 function by_id(id) {
16 return document.getElementById(id);
17 }
18 function are_cookies_disabled() {
19 return navigator && !navigator.cookieEnabled;
20 }
21 function set_display(id, status)
22 {
23 var e = by_id(id);
24 if (e) {
25 e.style.display = status;
26 }
27 }
28 function is_opted_out() {
29 // piwik_ignore check for BC.
30 return document.cookie && (document.cookie.indexOf(cookiename + '=1') !== -1 || document.cookie.indexOf('piwik_ignore=') !== -1);
31 }
32 function update_status()
33 {
34 if (are_cookies_disabled()) {
35 set_display('matomo_outout_err_cookies', 'block');
36 set_display('matomo_optout_checkbox', 'none');
37 } else if (is_opted_out()) {
38 set_display('matomo_opted_out_intro', 'block');
39 set_display('matomo_opted_in_intro', 'none');
40 set_display('matomo_opted_out_label', 'inline');
41 set_display('matomo_opted_in_label', 'none');
42 by_id('matomo_optout_checkbox').checked = false;
43 } else {
44 set_display('matomo_opted_out_intro', 'none');
45 set_display('matomo_opted_in_intro', 'block');
46 set_display('matomo_opted_out_label', 'none');
47 set_display('matomo_opted_in_label', 'inline');
48 by_id('matomo_optout_checkbox').checked = true;
49 }
50 }
51 function on_ready(callback) {
52 if (document.readyState === 'complete' || document.readyState === 'interactive') {
53 setTimeout(callback, 1);
54 } else {
55 document.addEventListener('DOMContentLoaded', callback);
56 }
57 }
58
59 function set_cookie(name, val, expires, path, domain)
60 {
61 var cookie = name + '=' + val + ';expires=' + expires + ';SameSite=Lax;path=' + (path || '/');
62 if (domain) {
63 cookie += ';domain=' + domain;
64 }
65 document.cookie = cookie;
66 }
67
68 on_ready(function () {
69 update_status();
70
71 if (are_cookies_disabled()) {
72 return;
73 }
74
75 listen_event(by_id('matomo_optout_checkbox'),'change', function () {
76 var trackers = [];
77 if ('object' === typeof window.Piwik && 'function' === typeof Piwik.getAsyncTrackers) {
78 trackers = Piwik.getAsyncTrackers();
79 }
80 var value = 0;
81 var expires = 'Thu, 01 Jan 1970 00:00:01 GMT'
82 if (is_opted_out()) {
83 // for BC additionally remove any set piwik_ignore cookie
84 set_cookie('piwik_ignore', 0, expires, '/');
85 } else {
86 value = 1;
87 var expire = new Date();
88 expire.setTime(expire.getTime() + (86400 * 365 * 30 * 1000));
89 expires = expire.toGMTString();
90 }
91
92 if (trackers.length) {
93 // respect tracker settings
94 for (var i = 0; i < trackers.length; i++) {
95 set_cookie(cookiename, value, expires, trackers[i].getCookiePath(), trackers[i].getCookieDomain());
96 }
97 } else {
98 // fallback
99 set_cookie(cookiename, value, expires, '/');
100 }
101
102 update_status();
103 });
104 })
105 })();
106