forked from backdrop-contrib/matomo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matomo.js
34 lines (26 loc) · 999 Bytes
/
matomo.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
28
29
30
31
32
33
34
(function ($) {
$(document).ready(function() {
// Attach mousedown, keyup, touchstart events to document only and catch
// clicks on all elements.
$(document.body).bind("mousedown keyup touchstart", function(event) {
// Catch the closest surrounding link of a clicked element.
$(event.target).closest("a,area").each(function() {
if (Backdrop.settings.matomo.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
// Mailto link clicked.
_paq.push(["trackEvent", "Mails", "Click", this.href.substring(7)]);
}
});
});
// Colorbox: This event triggers when the transition has completed and the
// newly loaded content has been revealed.
if (Backdrop.settings.matomo.trackColorbox) {
$(document).bind("cbox_complete", function () {
var href = $.colorbox.element().attr("href");
if (href) {
_paq.push(["setCustomUrl", href]);
_paq.push(["trackPageView"]);
}
});
}
});
})(jQuery);