ga-event-track

A jQuery plugin to capture DOM events and send that data to Google Analytics.


Keywords
jquery, google, analytics
License
MIT
Install
bower install ga-event-track

Documentation

ga-event-track

DEPRECATED

This project is no longer maintained.

Build Status Code Climate

A jQuery plugin to capture DOM events and send data regarding the event to Google Analytics as a tracked event.

Dependencies

  • jQuery (tested with ~1.11.0)
  • Google Analytics Web Tracking - analytics.js

Install

bower install ga-event-track

Usage

  1. Add the dist folder's jquery.ga-event-track.min.js file to your website
<script src="jquery.ga-event-track.min.js"></script>

Forms

  1. Forms: On the body element, add a "ga-track-forms" class attribute to any webpage with forms you wish to track.
<body class="ga-track-forms">
...
  <form name="mncatplus"...>
    <input name="request" type="text"/>
    <input type="image" src="../path"/>
    <input type="radio" name="type" value="keyword"/>
    <input type="radio" name="type" value="title"/>
    <input type="radio" name="type" value="author"/>
  </form>
  1. When the form's onsubmit event is triggered, you'll capture:
Event Category Event Action Event Label
Form Submit { "location":{ "hostname":"www.lib.umn.edu", "pathname":"/" }, "name":"mncat-discovery", "inputs":{ "submit":"", "phrase":"beer" }, "media":"large", "date":1409081954817 }

Links

  1. Links: On the body element, add a "ga-track-links" class attribute if you wish to track links.
<body class="ga-track-links">
  ...
</body>
  1. When a link's onclick event is triggered, you'll capture:
Event Category Event Action Event Label
Links Click { "location":{ "hostname":"drupal.dev", "pathname":"/" }, "media":"large", "mouse":{ "pageX":200, "pageY":400 }, "href":"researchsupport", "text":"Researcher", "parents":"main|featured-items|researcher-support", "date":1409082445329 }

Scroll Depth

  1. Scroll Depth: On the body element, add a "ga-track-scroll" class attribute if you wish to capture scroll depth.
<body class="ga-track-scroll">
  ...
</body>
  1. When a user scrolls down the page, you'll collect scroll depth events.

Tests

Install the project's dependencies

npm install

Run the test suite

grunt test

Minify Javascript

uglifyjs src/* --source-map "dist/jquery.ga-event-track.min.js.map" -o "dist/jquery.ga-event-track.min.js"

Author

Eric Larson

Copyright and License

Copyright (c) 2013-2016 Regents of the University of Minnesota - The MIT License (MIT)