PageSourceSearch

https://insights.orviko.com/t.js

js orviko.com collected 2026-09-29 09:24:37 UTC 3,441 bytes, 131 lines download raw bytes

1(function () {
2  "use strict";
3  if (window.__oi_initialized) return;
4  window.__oi_initialized = true;
5
6  var script = document.currentScript;
7  var ENDPOINT = script.src.replace("/t.js", "/api/collect");
8  var SITE_ID = script.getAttribute("data-site");
9  if (!SITE_ID) return;
10
11  var VID_KEY = "_oi_vid";
12  var SID_KEY = "_oi_sid";
13  var STS_KEY = "_oi_sts";
14  var REF_KEY = "_oi_ref";
15  var TIMEOUT = 30 * 60 * 1000;
16
17  // Detect and persist affiliate ref parameter
18  var refParam = new URLSearchParams(location.search).get("ref");
19  if (refParam) {
20    localStorage.setItem(REF_KEY, refParam);
21  }
22
23  var vid = localStorage.getItem(VID_KEY);
24  if (!vid) {
25    vid = uid();
26    localStorage.setItem(VID_KEY, vid);
27  }
28  document.cookie =
29    VID_KEY + "=" + vid + ";path=/;max-age=31536000;SameSite=Lax";
30
31  function uid() {
32    return Date.now().toString(36) + Math.random().toString(36).substr(2, 9);
33  }
34
35  function getSession() {
36    var stored = sessionStorage.getItem(SID_KEY);
37    var ts = parseInt(sessionStorage.getItem(STS_KEY) || "0", 10);
38    var sid;
39    if (stored && Date.now() - ts < TIMEOUT) {
40      sid = stored;
41    } else {
42      sid = uid();
43      sessionStorage.setItem(SID_KEY, sid);
44    }
45    sessionStorage.setItem(STS_KEY, String(Date.now()));
46    document.cookie = SID_KEY + "=" + sid + ";path=/;max-age=1800;SameSite=Lax";
47    return sid;
48  }
49
50  function getUtm() {
51    var p = new URLSearchParams(location.search);
52    var u = {};
53    [
54      "utm_source",
55      "utm_medium",
56      "utm_campaign",
57      "utm_term",
58      "utm_content",
59    ].forEach(function (k) {
60      var v = p.get(k);
61      if (v) u[k] = v;
62    });
63    return u;
64  }
65
66  function send(data) {
67    data.site_id = SITE_ID;
68    data.visitor_id = vid;
69    data.session_id = getSession();
70    data.url = location.href;
71    data.pathname = location.pathname;
72    data.hostname = location.hostname;
73    data.referrer = document.referrer || "";
74    data.screen_width = screen.width;
75    data.screen_height = screen.height;
76    Object.assign(data, getUtm());
77
78    var ref = localStorage.getItem(REF_KEY);
79    if (ref) data.ref = ref;
80
81    var payload = JSON.stringify(data);
82    if (navigator.sendBeacon) {
83      navigator.sendBeacon(ENDPOINT, payload);
84    } else {
85      var xhr = new XMLHttpRequest();
86      xhr.open("POST", ENDPOINT, true);
87      xhr.setRequestHeader("Content-Type", "text/plain");
88      xhr.send(payload);
89    }
90  }
91
92  // Track initial page view
93  send({ type: "pageview" });
94
95  // SPA support — only fire when URL actually changes
96  var lastUrl = location.href;
97  var pushState = history.pushState;
98  var replaceState = history.replaceState;
99  history.pushState = function () {
100    pushState.apply(this, arguments);
101    setTimeout(function () {
102      if (location.href !== lastUrl) {
103        lastUrl = location.href;
104        send({ type: "pageview" });
105      }
106    }, 0);
107  };
108  history.replaceState = function () {
109    replaceState.apply(this, arguments);
110    setTimeout(function () {
111      if (location.href !== lastUrl) {
112        lastUrl = location.href;
113        send({ type: "pageview" });
114      }
115    }, 0);
116  };
117  window.addEventListener("popstate", function () {
118    if (location.href !== lastUrl) {
119      lastUrl = location.href;
120      send({ type: "pageview" });
121    }
122  });
123
124  // Expose for Stripe integration
125  window.__oi = {
126    vid: vid,
127    sid: function () {
128      return getSession();
129    },
130  };
131})();

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.