-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathga.js
27 lines (24 loc) · 933 Bytes
/
ga.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
const key = "G-21BKTD0NKN"; // Measurement ID for Google Analytics; this tag is used in gtag("config", ...)
gtag("config", key);
const isPWA = window.matchMedia("(display-mode: standalone)").matches;
const schema = /^-kiwi-news-(0x[a-fA-F0-9]{40})-key$/;
const usesDelegation = Object.keys(localStorage).some((key) =>
schema.test(key),
);
gtag("config", key, {
pwa_mode: isPWA ? "Standalone" : "Not Standalone",
uses_delegation: usesDelegation ? "Delegation" : "Wallet Connection",
});
// By configuring the measurement ID with gtag("config", key),
// all subsequent events automatically use that key.
// Therefore, there is no need to add a "send_to" parameter in trackEvent.
window.trackEvent = function(eventName, params) {
if (typeof gtag === "function") {
gtag("event", eventName, params);
}
};