forked from opentargets/ot-ui-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_matomo.js
More file actions
40 lines (38 loc) · 1.06 KB
/
init_matomo.js
File metadata and controls
40 lines (38 loc) · 1.06 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
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
(function() {
function registerUserVisit() {
getLoggedInUser()
.then(function(user) {
_paq.push(['setUserId', user]);
})
.finally(function() {
_paq.push(['setCustomUrl', window.location.href]);
_paq.push(['setDocumentTitle', window.document.title]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
});
}
var pushState = history.pushState;
history.pushState = function() {
pushState.apply(history, arguments);
registerUserVisit();
};
registerUserVisit();
})();
(function() {
var u = 'DISABLED';
if (u === 'DISABLED') {
return
}
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '1']);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = u + 'matomo.js';
s.parentNode.insertBefore(g, s);
})();