-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblazor-analytics.js
More file actions
33 lines (33 loc) · 1.32 KB
/
blazor-analytics.js
File metadata and controls
33 lines (33 loc) · 1.32 KB
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
28
29
30
31
32
33
window.dataLayer = window.dataLayer || [];
window.gtag = window.gtag || function () { dataLayer.push(arguments); };
gtag("js", new Date());
var GoogleAnalyticsInterop;
(function (GoogleAnalyticsInterop) {
function configure(trackingId, debug) {
if (debug === void 0) { debug = false; }
this.debug = debug;
var script = document.createElement("script");
script.async = true;
script.src = "https://www.googletagmanager.com/gtag/js?id=" + trackingId;
document.head.appendChild(script);
gtag("config", trackingId, { 'send_page_view': false });
if (this.debug) {
console.log("[GTAG][" + trackingId + "] Configured!");
}
}
GoogleAnalyticsInterop.configure = configure;
function navigate(trackingId, href) {
gtag("config", trackingId, { page_location: href });
if (this.debug) {
console.log("[GTAG][" + trackingId + "] Navigated: '" + href + "'");
}
}
GoogleAnalyticsInterop.navigate = navigate;
function trackEvent(eventName, eventData) {
gtag("event", eventName, eventData);
if (this.debug) {
console.log("[GTAG][Event triggered]: " + eventName);
}
}
GoogleAnalyticsInterop.trackEvent = trackEvent;
})(GoogleAnalyticsInterop || (GoogleAnalyticsInterop = {}));