matomo.js 995 B

12345678910111213141516171819202122232425262728293031323334
  1. (function ($) {
  2. $(document).ready(function() {
  3. // Attach mousedown, keyup, touchstart events to document only and catch
  4. // clicks on all elements.
  5. $(document.body).bind("mousedown keyup touchstart", function(event) {
  6. // Catch the closest surrounding link of a clicked element.
  7. $(event.target).closest("a,area").each(function() {
  8. if (Drupal.settings.matomo.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
  9. // Mailto link clicked.
  10. _paq.push(["trackEvent", "Mails", "Click", this.href.substring(7)]);
  11. }
  12. });
  13. });
  14. // Colorbox: This event triggers when the transition has completed and the
  15. // newly loaded content has been revealed.
  16. if (Drupal.settings.matomo.trackColorbox) {
  17. $(document).bind("cbox_complete", function () {
  18. var href = $.colorbox.element().attr("href");
  19. if (href) {
  20. _paq.push(["setCustomUrl", href]);
  21. _paq.push(["trackPageView"]);
  22. }
  23. });
  24. }
  25. });
  26. })(jQuery);