Socket
Socket
Sign inDemoInstall

@segment/analytics-next

Package Overview
Dependencies
Maintainers
285
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@segment/analytics-next

Analytics Next (aka Analytics 2.0) is the latest version of Segment’s JavaScript SDK - enabling you to send your data to any tool without having to learn, test, or use a new API every time.


Version published
Maintainers
285
Created

What is @segment/analytics-next?

@segment/analytics-next is a JavaScript library that allows you to easily integrate Segment's analytics capabilities into your web applications. It provides a simple API to track user interactions, identify users, and manage analytics data across multiple platforms and services.

What are @segment/analytics-next's main functionalities?

Track Events

The `track` method allows you to record any actions your users perform. This example tracks a 'Button Clicked' event with additional properties.

const analytics = require('@segment/analytics-next');

(async () => {
  const [response] = await analytics.load({ writeKey: 'YOUR_WRITE_KEY' });
  analytics.track('Button Clicked', {
    buttonName: 'Subscribe'
  });
})();

Identify Users

The `identify` method lets you associate a user with their unique ID and traits. This example identifies a user with an ID and additional traits like email and name.

const analytics = require('@segment/analytics-next');

(async () => {
  const [response] = await analytics.load({ writeKey: 'YOUR_WRITE_KEY' });
  analytics.identify('userId123', {
    email: 'user@example.com',
    name: 'John Doe'
  });
})();

Page Tracking

The `page` method records page views on your website. This example tracks a page view for the 'Home Page'.

const analytics = require('@segment/analytics-next');

(async () => {
  const [response] = await analytics.load({ writeKey: 'YOUR_WRITE_KEY' });
  analytics.page('Home Page');
})();

Other packages similar to @segment/analytics-next

FAQs

Package last updated on 03 Sep 2024

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