piwik.js 1.1 KB

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