-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathanalytics.js
More file actions
64 lines (56 loc) · 1.62 KB
/
analytics.js
File metadata and controls
64 lines (56 loc) · 1.62 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// IBM Analytics setup for Mintlify
// Configure this script as a custom JS file in your Mintlify settings
(function() {
// Only run in production or when explicitly enabled
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
console.log('IBM Analytics disabled in development');
return;
}
// Set up IBM Analytics configuration
window.idaPageIsSPA = true;
// Configure digital data
window.digitalData = {
page: {
category: {
primaryCategory: 'PC340'
},
pageInfo: {
ibm: {
siteId: 'granite-developer-enablement'
}
}
}
};
// Configure IBM Analytics settings
window._ibmAnalytics = {
settings: {
name: 'granite-developer-enablement',
isSpa: true
}
};
// Load IBM Analytics library
var script = document.createElement('script');
script.src = 'https://1.www.s81c.com/common/stats/ibm-common.js';
script.type = 'text/javascript';
script.defer = true;
document.head.appendChild(script);
function trackPageview() {
// Wait for IBM Analytics to load, then track pageview
setTimeout(function() {
if (window.ibmStats && typeof window.ibmStats.pageview === 'function') {
window.ibmStats.pageview();
}
}, 100);
}
// Track initial page load
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', trackPageview);
} else {
trackPageview();
}
if(window.navigation) {
window.navigation.addEventListener("navigate", trackPageview)
} else {
window.addEventListener('popstate', trackPageview);
}
})();