meteor-analyticsjs
Segment.io's Analytics.js packaged for Meteor.
Exposes analytics
as a global client variable.
Setup
Set your api key with Meteor.settings as Meteor.settings.public.analytics_api_key
1{ 2 "public": { 3 "analytics_api_key": "YOUR-ANALYTICS-API-KEY", 4 "analytics_localhost_active":true //optional, this will enable analytics on localhost, disabled by default 5 } 6}
Usage
Here's how to track page loads, if you're using iron-router
:
1Router.onRun(function(){ 2 if(Session.equals('AnalyticsJS_loaded', true)) 3 analytics.page(this.path); 4});
For more types of tracking, refer to the Analytics.js documentation.
Server side tracking
This package is for client side metrics only. You'll want the npm
package and the analytics-node
npm to record server side metrics. See https://github.com/nate-strauser/meteor-analyticsjs/issues/10