Code Monkey home page Code Monkey logo

analytics's Introduction

Complete analytics integration for Meteor

Use one API to record and send your data from your Meteor app to your analytics platforms.

Installation

> meteor add okgrow:analytics

Configuration

Add various platforms by adding each tool's configuration to your settings.json file:

{
  "public": {
    "analyticsSettings": {
      // Add your analytics tracking id's here (remove this line before running)
      "Google Analytics" : {"trackingId": "Your tracking ID"},
      "GoSquared"        : {"siteToken": "Your site token (eg. GSN-123456-Y)"},
      "Mixpanel"         : {"token":  "your token", "people": true},
      "KISSmetrics"      : {"apiKey": "your api key"},
      "UserVoice"        : {"apiKey": "your api key"},
      "Sentry"           : {"config": "your config key"},
      "Segment.io"       : {"apiKey": "your api key"},
      "Keen IO"          : {"projectId": "your project id", "writeKey": "your write key"}
    }
  }
}

It's important to note that service names and API key-names provided above are specific to the platform. Make sure to use the correct service name and key shown for the plaform you're adding.

Page views

Compatible with either IronRouter or FlowRouter (even pre-2.0 FlowRouter), this package will log page views automatically. For FlowRouter, the page is logged with the follow parameters:

  • path: path part of the URL
  • title: the page's title, as specified by the route
  • url: hostname + path
  • name: route name if set, otherwise equivalent to path
  • search: the URL's query string, if provided. blank otherwise
  • referrer: hostname + old path, if coming from a previous route

To manually log a page view: analytics.page('page name')

Log signin/signout

If you have the accounts package installed, this package will automatically track when a user logs in and logs out. Logging in will call identify on the user and associate their Meteor.userId to their previous anonymous activities.

Event tracking

Add tracking on any event simply by calling the analytics.track() function:

analytics.track("Bought Ticket", {
  eventName: "Wine Tasting",
  couponValue: 50,
});

See the analytics.js track documentation for a full description of track() and all the other functions available in this package.

Track visitor scrolling

Josh Owens' article, Google Analytics events, goals, and Meteor.js, goes over a great way to capture how far a visitor has scrolled down a page.

Configuration

Q: What other analytics platforms are supported?
A: This package uses the analytics.js open source project under the hood which does support many additional platforms. The challenge is using the correct API key-name and any other required options, but these setting can usually be found by looking at the individual integration repos. If you've used other services with the open-source codebase and can confirm the API options please submit a PR to update this example!

Browser Policy

If your project uses the Browser Policy package, we've included the Google Analytics & Mixpanel domains in our browser policy configuration. Any additional services you add will need to be added to your browser policy config as well.

example
// file: lib/browser-policy.js

BrowserPolicy.content.allowOriginForAll("www.google-analytics.com");
BrowserPolicy.content.allowOriginForAll("cdn.mxpnl.com");

If your project doesn't use this package, then don't worry as it will not affect your usage.

Debugging

When adding your platforms and setting events to track, you'll probably want to keep debug on locally. This will log all the analytics package's activity to the console.
In the console:
> analytics.debug()

Turn debug off with analytics.debug(false)

analytics's People

Contributors

ctaloi avatar deanius avatar deanrad avatar elie222 avatar hpx7 avatar marvinmarnold avatar ograycode avatar pauldowman avatar pem-- avatar rgould avatar robertlowe avatar tsemana avatar wehrlock avatar

Watchers

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