Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
/ analytics-node Public archive

The hassle-free way to integrate analytics into any node application.

License

Notifications You must be signed in to change notification settings

segmentio/analytics-node

Repository files navigation

Please install the new node SDK: @segment/analytics-node.

analytics-node

A Node.js client for Segment — The hassle-free way to integrate analytics into any application.

⚠️ Community ⚠️

This library is community supported. Segment does not manage or update this library. We suggest forking the repo if changes are needed for your project.

We highly recommend using our upgraded Analytics-Node to benefit from feature enhancements and ongoing support.

You can't fix what you can't measure

Analytics helps you measure your users, product, and business. It unlocks insights into your app's funnel, core business metrics, and whether you have product-market fit.

How to get started

  1. Collect analytics data from your app(s).
    • The top 200 Segment companies collect data from 5+ source types (web, mobile, server, CRM, etc.).
  2. Send the data to analytics tools (for example, Google Analytics, Amplitude, Mixpanel).
    • Over 250+ Segment companies send data to eight categories of destinations such as analytics tools, warehouses, email marketing and remarketing systems, session recording, and more.
  3. Explore your data by creating metrics (for example, new signups, retention cohorts, and revenue generation).
    • The best Segment companies use retention cohorts to measure product market fit. Netflix has 70% paid retention after 12 months, 30% after 7 years.

Segment collects analytics data and allows you to send it to more than 250 apps (such as Google Analytics, Mixpanel, Optimizely, Facebook Ads, Slack, Sentry) just by flipping a switch. You only need one Segment code snippet, and you can turn integrations on and off at will, with no additional code. Sign up with Segment today.

Why?

  1. Power all your analytics apps with the same data. Instead of writing code to integrate all of your tools individually, send data to Segment, once.

  2. Install tracking for the last time. We're the last integration you'll ever need to write. You only need to instrument Segment once. Reduce all of your tracking code and advertising tags into a single set of API calls.

  3. Send data from anywhere. Send Segment data from any device, and we'll transform and send it on to any tool.

  4. Query your data in SQL. Slice, dice, and analyze your data in detail with Segment SQL. We'll transform and load your customer behavioral data directly from your apps into Amazon Redshift, Google BigQuery, or Postgres. Save weeks of engineering time by not having to invent your own data warehouse and ETL pipeline.

    For example, you can capture data on any app:

    analytics.track({ userId: '019mr8mf4r', event: 'Order Completed', properties: { price: 99.84 }});

    Then, query the resulting data in SQL:

    select * from app.order_completed
    order by price desc

🚀 Startup Program

If you are part of a new startup (<$5M raised, <2 years since founding), we just launched a new startup program for you. You can get a Segment Team plan (up to $25,000 value in Segment credits) for free up to 2 years — apply here!

Installation

$ npm install analytics-node

Usage

const Analytics = require('analytics-node');

const client = new Analytics('write key');

client.track({
  event: 'event name',
  userId: 'user id'
});

Notes

Defining sentAt in the payload will cause the specified timestamp to be ignored

Documentation

Documentation is available at https://segment.com/libraries/node.

License

Copyright © 2017 Segment Inc. <[email protected]>