Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

analytics-node

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-node

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

  • 0.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
312K
decreased by-29.58%
Maintainers
2
Weekly downloads
 
Created

What is analytics-node?

The analytics-node npm package is a client for Segment's server-side analytics. It allows you to send data to Segment from your Node.js applications, enabling you to track user actions, identify users, and manage groups. This data can then be routed to various analytics and marketing tools.

What are analytics-node's main functionalities?

Track

The `track` method allows you to record any actions your users perform. This is useful for tracking events like purchases, sign-ups, or any other user activity.

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

analytics.track({
  userId: 'user123',
  event: 'Item Purchased',
  properties: {
    item: 'Sword of Truth',
    price: 300
  }
});

Identify

The `identify` method is used to associate user data with a specific user ID. This helps in creating a user profile with traits like name, email, and other custom attributes.

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

analytics.identify({
  userId: 'user123',
  traits: {
    name: 'John Doe',
    email: 'john.doe@example.com',
    plan: 'premium'
  }
});

Group

The `group` method allows you to associate a user with a group, such as a company or organization. This is useful for B2B applications where you need to track users within the context of their organization.

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

analytics.group({
  userId: 'user123',
  groupId: 'group123',
  traits: {
    name: 'Company XYZ',
    industry: 'Technology'
  }
});

Page

The `page` method is used to record page views on your website. This is useful for tracking which pages users are visiting and how they navigate through your site.

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

analytics.page({
  userId: 'user123',
  category: 'Docs',
  name: 'Node.js Library',
  properties: {
    url: 'https://example.com/docs/node'
  }
});

Alias

The `alias` method is used to merge two user identities, effectively linking an anonymous user with an identified user. This is useful when a user signs up or logs in, and you want to associate their previous anonymous actions with their new identified profile.

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

analytics.alias({
  previousId: 'temp123',
  userId: 'user123'
});

Other packages similar to analytics-node

Keywords

FAQs

Package last updated on 20 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc