Giter Site home page Giter Site logo

thomasdebruin / jquery-analytics-event-tracking Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pascalvgemert/jquery-analytics-event-tracking

0.0 1.0 0.0 162 KB

JQuery plugin for Event Tracking based on Universal Analytics (analytics.js)

HTML 40.36% JavaScript 59.64%

jquery-analytics-event-tracking's Introduction

jquery-analytics-event-tracking

JQuery plugin for Event Tracking based on Universal Analytics (analytics.js)

NOTICE

Only works with the new Analytics code: Universal Analytics (analytics.js)

Usage

Use $('body').analyticsEventTracking(); to initialize the plugin.

All elements in the body tag which contain the class .track will be tracked.

Add data-category="category-name" to specify the category (default: 'General')
Add data-action="click" to specify the action (default: 'click')
Add data-label="label-name" to specify the label (default: '')
Add data-value="1" to specify the value (default: 1)

Advanced usage

To use events other than the 'click' event, extend the .track with one of the following:

  • -focus .track-focus - tracks event on focus
  • -blur .track-blur - tracks event on blur
  • -mouseover .track-mouseover - tracks event on mouseover
  • -change .track-change - tracks event on change
  • -completed .track-completed - tracks event on blur event when a value is set

Dependencies

The plugin requires jQuery v1.7 (or higher). (HTML5 data attributes required) The plugin requires Google Analytics script with ga function. (analytics.js)

Options

  • selector : The selector of the elements to track (default: '.track')
  • default_category : The default category, when not provided as date-category="category-name" (default: 'General')

Example

<form action="" method="post">
    <label for="username">Username:</label>
    <input type="email" name="username" value="" id="username" class="track-blur" data-category="login" data-action="completed" data-label="username" />

    <label for="password">Password:</label>
    <input type="password" name="password" value="" id="password" class="track-blur" data-category="login" data-action="completed" data-label="password" />

    <input type="submit" value="Log in" class="track" data-category="login" data-action="click" data-label="button" data-value="2" />
</form>

Author

Pascal van Gemert

http://pascalvangemert.nl/

jquery-analytics-event-tracking's People

Contributors

pascalvgemert avatar

Watchers

Thomas de Bruin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.