Automatic Analytics for Meteor and Beyond


Automatic Page Tracking and User Identification Analytics for Meteor and Beyond

Analytics is often an important requirement for applications and websites.

At OK GROW! we’ve been supporting the Meteor platform with an analytics package that made setup and configuration of analytics in your Meteor application very simple for the most common use cases, namely page or screen tracking and user identification.

Making Analytics Automatic

Setting up analytics in your app or website can sometimes be complicated and cumbersome. If you use multiple, different analytics platforms, this complexity multiplies. An ideal solution would do two things:

  1. Support multiple analytics platforms with a single, unified API.
  2. Easily setup and configure, especially for the most common use cases.

Multiple Analytics Platforms

Segment has offered a unified platform for doing website and application analytics that funnels analytics events to multiple analytics platforms for you.

To provide the most flexibility, we no longer bundle Segment’s analytics.js package. You can install their full package and get all of their integrations:

npm install --save analytics.js

Alternatively, follow the “read me” instructions to create a custom analytics.js that includes only the integrations you need.

Building on Segment’s analytics package helps us solve the first problem. Most developers can just use that package if that’s the only problem they wanted to solve. We wanted to help developers by making the two most common use cases, page tracking and user identification, both incredibly simple and, better yet, fully automatic.

Automatic Page Tracking

One of the most common analytics use cases is tracking how a user moves through your application or website. Earlier versions of OK GROW!’s analytics package, only supported automatic page tracking with Iron Router and Flow Router.

To support more routers we’ve now taken things a step further. Wide adoption of the History API enabled us to make automatic page tracking completely router agnostic. Being router agnostic opens the package to the wider JavaScript community. Therefore, we’ve moved the core analytics functionality into an NPM package.

@okgrow/auto-analytics

Our new @okgrow/auto-analytics package moves the core automatic, router-agnostic page tracking into a package usable by the entire JavaScript community. This package still integrates the most popular analytics platforms from Segment into a single, seamless, easy to use package that can be quickly configured to automatically report page views to your analytics accounts.

Getting started is as simple as:

npm install --save @okgrow/auto-analytics

Then just configure your analytics services:

import OKGAnalytics from '@okgrow/auto-analytics';

const settings = {
  "Google Analytics" : {"trackingId": "Your tracking ID"},
  "Amplitude"        : {"apiKey": "..."},
  "Chartbeat"        : {"uid": "..."},
  "comScore"         : {"c2": "..."},
  "HubSpot"          : {"portalId": "..."},
  "Intercom"         : {"appId": "..."},
  "Keen IO"          : {"projectId": "...", "writeKey": "..."},
  "KISSmetrics"      : {"apiKey": "..."},
  "Mixpanel"         : {"token":  "...", "people": true},
  "Quantcast"        : {"pCode": "..."},
  "Segment.io"       : {"apiKey": "..."}
};

OKGAnalytics(settings);

Learn more about the @okgrow/auto-analytics package at our Github repository.

Automatic User Identification

Another common use case is to identify the specific user using your application and know what specific users or categories of users are doing in your app or website. It would be great to hook into the user authentication system to automatically identify your users to your analytics platforms.

Meteor, well known for having a crazy easy and simple to install and configure user accounts and authentication system enables us to solve this problem in a reliable and standard way for Meteor applications that use Meteor’s accounts package.

Since this functionality is currently Meteor-only, it remains as an Atmosphere package that leverages Meteor’s accounts package.

okgrow:analytics

The okgrow:analytics Atmosphere package has been around for a while. The latest version, 3.0, still includes the automatic page tracking functionality, but now gets this functionality from the aforementioned @okgrow/auto-analytics NPM package while building on that package and still providing fully automatic user identification for users of Meteor’s accounts package.

Like the NPM package, getting started with this package is as simple as:

meteor add okgrow:analytics

NOTE: The okgrow:analytics includes the @okgrow/auto-analytics package as a dependency, so it doesn’t need to be installed separately.

Configuration with the Meteor package is slightly simpler. Just add your configuration to the settings.json file like this:

{
  "public": {
    "analyticsSettings": {
      "Google Analytics" : {"trackingId": "Your tracking ID"},
      "Amplitude"        : {"apiKey": "..."},
      "Chartbeat"        : {"uid": "..."},
      "comScore"         : {"c2": "..."},
      "HubSpot"          : {"portalId": "..."},
      "Intercom"         : {"appId": "..."},
      "Keen IO"          : {"projectId": "...", "writeKey": "..."},
      "KISSmetrics"      : {"apiKey": "..."},
      "Mixpanel"         : {"token":  "...", "people": true},
      "Quantcast"        : {"pCode": "..."},
      "Segment.io"       : {"apiKey": "..."}
    }
  }
}

Then run your Meteor app:

meteor --settings settings.json

Future Directions

While we’re not 100% certain what directions the OK GROW! analytics packages will go in the future, we recognize the value the packages contribute and are considering various ideas to continue improving the capabilities, flexibility and overall usefulness based on our own experiences developing applications and websites for clients as well as feedback from the community.

We always welcome suggestions. Feel free to open an issue on the appropriate Github repo to make a suggestion. We also welcome pull requests if you have implemented new, valuable functionality for the community of @okgrow/auto-analytics and okgrow:analytics developers.

Let's stay connected. Join our monthly newsletter to receive updates on events, training, and helpful articles from our team.