Skip to content

Commit f2901d3

Browse files
committed
feat: tracking scripts
1 parent 24434e5 commit f2901d3

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

‎tracking.js‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Global tracking scripts for Agent Control docs
2+
// Mintlify automatically includes .js files in the content directory on every page.
3+
4+
(function () {
5+
if (typeof window === "undefined" || typeof document === "undefined") return;
6+
7+
// --- Helper to inject external scripts safely ---
8+
function loadScriptOnce(id, src, options) {
9+
if (id && document.getElementById(id)) return;
10+
var script = document.createElement("script");
11+
if (id) script.id = id;
12+
script.src = src;
13+
script.async = options && options.async !== false; // default true
14+
if (options && options.defer) script.defer = true;
15+
document.head.appendChild(script);
16+
}
17+
18+
// --- Google Analytics 4 (G-RN0NJCYSCQ) ---
19+
(function setupGA4() {
20+
// Load gtag.js
21+
loadScriptOnce(
22+
"ga4-gtag",
23+
"https://www.googletagmanager.com/gtag/js?id=G-RN0NJCYSCQ",
24+
{ async: true }
25+
);
26+
27+
window.dataLayer = window.dataLayer || [];
28+
function gtag() {
29+
window.dataLayer.push(arguments);
30+
}
31+
// Expose globally to match GA expectations
32+
window.gtag = window.gtag || gtag;
33+
34+
gtag("js", new Date());
35+
gtag("config", "G-RN0NJCYSCQ");
36+
})();
37+
38+
// --- Primer analytics ---
39+
loadScriptOnce(
40+
"primer-analytics",
41+
"https://analytics.sayprimer.com/primerAnalytics.js?clientId=661c794c-5933-4bd6-8ba3-db405ece255a",
42+
{ async: true }
43+
);
44+
45+
// --- HubSpot tracking ---
46+
loadScriptOnce(
47+
"hs-script-loader",
48+
"https://js-na2.hs-scripts.com/23114811.js",
49+
{ async: true, defer: true }
50+
);
51+
52+
// --- Signals script (cr-relay) ---
53+
(function () {
54+
if (typeof window === "undefined") return;
55+
if (typeof window.signals !== "undefined") return;
56+
57+
var script = document.createElement("script");
58+
script.src =
59+
"https://cdn.cr-relay.com/v1/site/e9a1e4dd-e943-4f5f-9626-88d3ca665192/signals.js";
60+
script.async = true;
61+
62+
var methods = ["page", "identify", "form"];
63+
var signalsStub = [];
64+
signalsStub._opts = { apiHost: "https://api.cr-relay.com" };
65+
methods.forEach(function (method) {
66+
signalsStub[method] = function () {
67+
signalsStub.push([method, arguments]);
68+
return signalsStub;
69+
};
70+
});
71+
72+
window.signals = signalsStub;
73+
document.head.appendChild(script);
74+
})();
75+
})();
76+

0 commit comments

Comments
 (0)