PageSourceSearch

https://www.sirrobertpeelstockport.co.uk/wp-content/plugins/punchp…/scripts/utm-attribution.js?ver=1.0.0

js sirrobertpeelstockport.co.uk collected 2026-10-06 10:58:11 UTC 3,784 bytes, 159 lines download raw bytes

1(function () {
2  var config = window.pppUtmAttribution || {};
3  var parameters = Array.isArray(config.parameters) ? config.parameters : [
4    'utm_source',
5    'utm_medium',
6    'utm_campaign',
7    'utm_content',
8    'utm_term'
9  ];
10  var cookieDuration = parseInt(config.cookieDuration, 10) || 90;
11  var utmValues = getUtmValues();
12  var consentStatus = getAttributionConsentStatus();
13
14  document.addEventListener('click', function (event) {
15    if (!isConsentButton(event.target)) {
16      return;
17    }
18
19    checkConsentAfterUpdate(0);
20  });
21
22  if (consentStatus === 'rejected') {
23    deleteAttributionCookies();
24  }
25
26  if (!hasUtmValues(utmValues)) {
27    return;
28  }
29
30  if (consentStatus === 'accepted') {
31    setAttributionCookies(utmValues);
32  }
33
34  function getUtmValues() {
35    var values = {};
36
37    try {
38      var searchParams = new URLSearchParams(window.location.search);
39
40      parameters.forEach(function (parameter) {
41        var value = searchParams.get(parameter);
42
43        if (value) {
44          values[parameter] = value;
45        }
46      });
47    } catch (error) {}
48
49    return values;
50  }
51
52  function hasUtmValues(values) {
53    return Object.keys(values).length > 0;
54  }
55
56  function setAttributionCookies(values) {
57    Object.keys(values).forEach(function (name) {
58      setCookie(name, values[name], cookieDuration);
59    });
60  }
61
62  function deleteAttributionCookies() {
63    parameters.forEach(function (name) {
64      setCookie(name, '', -1);
65    });
66  }
67
68  function setCookie(name, value, days) {
69    var date = new Date();
70    var cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
71
72    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
73    cookie += '; expires=' + date.toUTCString();
74    cookie += '; max-age=' + (days * 24 * 60 * 60);
75    cookie += '; path=/';
76    cookie += '; SameSite=Lax';
77
78    if (window.location.protocol === 'https:') {
79      cookie += '; Secure';
80    }
81
82    document.cookie = cookie;
83  }
84
85  function checkConsentAfterUpdate(attempt) {
86    window.setTimeout(function () {
87      var status = getAttributionConsentStatus();
88
89      if (status === 'accepted') {
90        setAttributionCookies(utmValues);
91        return;
92      }
93
94      if (status === 'rejected') {
95        deleteAttributionCookies();
96        return;
97      }
98
99      if (attempt < 10) {
100        checkConsentAfterUpdate(attempt + 1);
101      }
102    }, 250);
103  }
104
105  function getAttributionConsentStatus() {
106    var mooveConsent = getCookieValue('moove_gdpr_popup');
107
108    if (!mooveConsent) {
109      return 'unknown';
110    }
111
112    try {
113      mooveConsent = decodeURIComponent(mooveConsent);
114      mooveConsent = JSON.parse(mooveConsent);
115    } catch (error) {
116      return 'unknown';
117    }
118
119    if (isConsentValueAccepted(mooveConsent.thirdparty) ||
120      isConsentValueAccepted(mooveConsent.advanced)) {
121      return 'accepted';
122    }
123
124    return 'rejected';
125  }
126
127  function isConsentValueAccepted(value) {
128    return value === '1' || value === 1 || value === true || value === 'true';
129  }
130
131  function getCookieValue(name) {
132    var cookiePrefix = name + '=';
133    var cookies = document.cookie ? document.cookie.split('; ') : [];
134
135    for (var i = 0; i < cookies.length; i++) {
136      if (cookies[i].indexOf(cookiePrefix) === 0) {
137        return cookies[i].substring(cookiePrefix.length);
138      }
139    }
140
141    return '';
142  }
143
144  function isConsentButton(target) {
145    if (!target || !target.closest) {
146      return false;
147    }
148
149    return !!target.closest(
150      '.moove-gdpr-infobar-allow-all, ' +
151      '.moove-gdpr-infobar-reject-btn, ' +
152      '.moove-gdpr-modal-allow-all, ' +
153      '.moove-gdpr-modal-reject-all, ' +
154      '.moove-gdpr-modal-reject-btn, ' +
155      '.moove-gdpr-modal-save-settings, ' +
156      '.moove-gdpr-modal-save-all'
157    );
158  }
159})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.