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
mixpanel
Mixpanel is an advanced analytics service that helps improve web and mobile applications by tracking how users interact & engage with them. It offers similar functionalities to analytics-node, such as tracking events, identifying users, and creating user profiles. However, Mixpanel also provides more advanced features like A/B testing and in-depth funnel analysis.
amplitude
Amplitude is a product analytics service that helps teams understand user behavior, ship the right features, and improve business outcomes. Like analytics-node, it allows for event tracking and user identification. Amplitude is known for its powerful analytics capabilities, including cohort analysis, user segmentation, and retention tracking.
heap
Heap automatically captures every user action in your web or mobile app and lets you analyze it all retroactively. It offers similar functionalities to analytics-node, such as tracking events and identifying users. Heap's main advantage is its automatic data capture, which eliminates the need for manual event tracking.
keen.io
Keen.io is a data analytics platform that allows you to collect, analyze, and visualize event data. It provides similar functionalities to analytics-node, including event tracking and user identification. Keen.io is highly customizable and offers powerful data visualization tools, making it a good choice for custom analytics solutions.
analytics-node
analytics-node is a node.js client for Segment.io
Documentation
Documentation is available at https://segment.io/libraries/node.
License
WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|
(The MIT License)
Copyright (c) 2013 Segment.io Inc. friends@segment.io
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.