PageSourceSearch

https://www.nzherald.co.nz/pf/resources/scripts/tracking/data-ref.js?d=1068

js nzherald.co.nz collected 2026-09-24 07:39:45 UTC 1,722 bytes, 49 lines download raw bytes

1(function () {
2  "use strict";
3
4  const publish =
5    window?.NZME?.publish ||
6    function (type, vals) {
7      console.log(type, vals);
8    };
9
10  // check is the device has click event
11  var clickEvent = window.ontouchstart ? "touchstart" : "click";
12  document.addEventListener(clickEvent, function (e) {
13    var refElement, refNavTrackingElement;
14    var targetName = e.target && e.target.tagName && e.target.tagName.toLowerCase();
15
16    if (targetName === "a" || targetName === "button") {
17      refElement = e.target.getAttribute("data-ref-page-element");
18      refNavTrackingElement = e.target.getAttribute("data-nav-tracking-element");
19    } else if (["time", "h3", "img", "svg", "use"].includes(targetName)) {
20      refElement = e.currentTarget.activeElement.getAttribute("data-ref-page-element") || undefined;
21      refNavTrackingElement =
22        e.currentTarget.activeElement.getAttribute("data-nav-tracking-element") || undefined;
23    }
24
25    if (refElement) {
26      gtm.clickTag(refElement, "pv");
27      storeRefPageElement(refElement, "ref_page_element");
28    }
29
30    if (refNavTrackingElement) {
31      gtm.clickTag(refNavTrackingElement, "rpe");
32      storeRefPageElement(refNavTrackingElement, "nav_tracking_element");
33    }
34  });
35
36  function storeRefPageElement(element, elementType) {
37    try {
38      var vpv = JSON.parse(localStorageWrapper.getItem("vpv"));
39
40      if (vpv && element) {
41        var key =
42          elementType === "nav_tracking_element" ? "nav_tracking_element" : "ref_page_element";
43        localStorageWrapper.setItem("vpv", JSON.stringify(Object.assign(vpv, { [key]: element })));
44      }
45    } catch (err) {
46      publish("SCRIPT_ERROR", [err, "storeRefPageElement"]);
47    }
48  }
49})();

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.