GithubHelp home page GithubHelp logo

kidgodzilla / ember-google-analytics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ryanto/ember-google-analytics

0.0 2.0 0.0 567 KB

Ember.JS Plugin that makes Google Analytics just work.

License: MIT License

Ruby 15.78% JavaScript 84.22%

ember-google-analytics's Introduction

Ember Google Analytics

A plugin that allows your Ember application to work with Google Analytics. Thanks to Matthew Beale (@mixonic) for PR #3453 that made this plugin really easy to write.

Usage

You should include ember-google-analytics.js on your page. Since this plugin depends on Ember.js you will have to include Ember first. You will also need to include the snipit of JavaScript that Google Analytics gives you. Follow the directions they provide.

Tracking Page Views

Once included your router will automatically send a page view event to Google Analytics everytime the URL changes.

Tracking Additional Events

You can track custom events with this plugin. If you have a controller action that you wish to track you can use the Ember.GoogleAnalyticsTrackingMixin like so.

App.VideoController = Ember.Controller.extend(
  Ember.GoogleAnalyticsTrackingMixin, {

  actions: {
    play: function() {
      // ...
      //this.trackEvent('category', 'action')
      this.trackEvent('video', 'play');
      // or
      //this.trackEvent('category', 'action', 'label', value)
      this.trackEvent('video', 'play', 'youtube', 1);
    }
  }
});

The mixin can be applied to any Ember object.

Categories, Actions, and Labels

There are four parts to an Event. Each individual Event you want to track must be tagged with at least two of these parts; the other two are optional but recommended.

  • Category (required): The category is at the top of the hierarchy. It’s a way to bundle user activity together. "Slideshow", "Videos", and "Downloads" are good examples of categories, though you can be as specific or broad as your content requires.
  • Action (required): The action is literally what the user does. For a video player example, potential actions might be: play, pause, share, get embed link, etc.
  • Label (optional): Provides a bit more information about the user's action. For example, if you are using events to track a video player you might record the movie name as the label when an action occurs. That provides more context to what the user is doing.
  • Value (optional): Any positive integer value. It’s a number. You can use it to count things, like dollars or seconds. If you choose to use your event as a goal, then you can specify that Google Analytics use the event value as the goal value.

Logging

To enable console logging any events or page views sent to Google Analytics:

window.ENV = window.ENV || {};
window.ENV.LOG_EVENT_TRACKING = true;

Development

This plugin is built with rake pipeline, which requires Ruby. To get started:

bundle install
rackup

Edit code and visit http://localhost:9292 to run tests.

ember-google-analytics's People

Contributors

ryanto avatar spra85 avatar jbalaty avatar andyhot avatar

Watchers

James Cloos 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.