Sha256: 05ddc9deaa14ae947349115ffa7ed6bb49de241876a0e34785e126dae4526c72

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

/**
 * Panmind Analytics JS API
 *
 * TODO: Documentation
 */
(function ($) {
  $.pmTrackAjaxView = function () {
    if (typeof (_gaq) == 'undefined') return;

    try {
      _gaq.push (['_trackPageview', $.location.getPathForTracking ()]);
    } catch (e) { }
  };

  $.pmTrackEvent = function (category, action) {
    if (typeof (_gaq) != 'undefined')

    try {
      _gaq.push (['_trackEvent', category, action]);
    } catch (e) { }
  };

  var trackClick = function (elem, fn) {
    if (typeof (_gaq) != 'undefined')
      $(elem).click (function () {
        try { fn.apply (this); } catch (e) { }
      });

    return elem;
  };

  $.fn.pmTrackPageView = function () {
    return trackClick (this, function () {
      _gaq.push (['_trackPageview', $(this).attr ('href')]);
    });
  };

  $.fn.pmTrackDownload = function () {
    return trackClick (this, function () {
      _gaq.push (['_trackEvent', 'download', $(this).attr ('href')]);
    });
  };

  $.fn.pmTrackOutboundLink = function () {
    return trackClick (this, function () {
      _gaq.push (['_trackEvent', 'outbound', $(this).attr ('href')]);
    });
  };
}) (jQuery);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bigbro-1.0.0 js/jquery.analytics.js