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

analytics

Package Overview
Dependencies
Maintainers
2
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics

Lightweight analytics library for tracking events, page views, & identifying users. Works with any third party analytics provider via an extendable plugin system.

  • 0.8.14
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is analytics?

The 'analytics' npm package is a lightweight, pluggable library for tracking events, user data, and more. It provides a simple API to integrate with various analytics services and manage user data.

What are analytics's main functionalities?

Track Events

This feature allows you to track custom events within your application. The code sample demonstrates how to initialize the analytics instance with a Google Analytics plugin and track a 'buttonClicked' event.

const Analytics = require('analytics').default;
const googleAnalytics = require('@analytics/google-analytics').default;

const analytics = Analytics({
  app: 'my-app',
  plugins: [
    googleAnalytics({
      trackingId: 'UA-1234567'
    })
  ]
});

analytics.track('buttonClicked', {
  category: 'User Interaction',
  label: 'Signup Button'
});

Identify Users

This feature allows you to identify users and associate them with specific data. The code sample shows how to identify a user with a unique ID and additional user information.

const Analytics = require('analytics').default;
const googleAnalytics = require('@analytics/google-analytics').default;

const analytics = Analytics({
  app: 'my-app',
  plugins: [
    googleAnalytics({
      trackingId: 'UA-1234567'
    })
  ]
});

analytics.identify('user-id-123', {
  name: 'John Doe',
  email: 'john.doe@example.com'
});

Page Views

This feature allows you to track page views within your application. The code sample demonstrates how to initialize the analytics instance and track a page view.

const Analytics = require('analytics').default;
const googleAnalytics = require('@analytics/google-analytics').default;

const analytics = Analytics({
  app: 'my-app',
  plugins: [
    googleAnalytics({
      trackingId: 'UA-1234567'
    })
  ]
});

analytics.page();

Other packages similar to analytics

Keywords

FAQs

Package last updated on 29 Jul 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