Coder Social home page Coder Social logo

burtbeckwith / google-analytics-tracker-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andresakata/google-analytics-tracker-plugin

0.0 2.0 0.0 109 KB

This plugin provides a simple way to embed your web application with page view tracking and event tracking of Google Analytics.

Groovy 50.12% Gosu 49.88%

google-analytics-tracker-plugin's Introduction

Google Analytics Tracker Plugin

This plugin provides a simple way to embed your web application with page view tracking and event tracking of Google Analytics.

Configuration

First of all, you need to set your analytics account id in Config.groovy.

google.analytics.account="UA-YOURACCOUNT-ID"

You can also set a debug flag to print messages in browser console everytime a _gaq.push occur.

google.analytics.debug=true

Usage

Put the following tag in the end of the pages you want to track:

<g:googleAnalyticsTracker/>

Tracking Events

To track a click event, you simply add a ga-tracked class in the element, and declare the attributes data-ga-category, data-ga-action and data-ga-label.

For example:

<a href="/about" class="ga-tracked" data-ga-category="home" data-ga-action="about" data-ga-label="label">About</a>

If you have elements that are loaded by Javascript, after the page is already loaded, and you want to track these elements, you must to use the GoogleAnalyticsTracker.bindTrackEvent function, passing the selector to these new elements.

For example:

GoogleAnalyticsTracker.bindTrackEvent(".new-elements.ga-tracked");

You can also call directly GoogleAnalyticsTracker.trackEvent, that will make a push to Google Analytics with the values you passed:

GoogleAnalyticsTracker.trackEvent("category", "action", "label");

google-analytics-tracker-plugin's People

Contributors

burtbeckwith avatar andresakata avatar

Watchers

 avatar  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.