A helper library for that allows to easily integrate analytics in your chatbot. You can read more about how to integrate and use Google Analytics in to your chatbot here.
Supported 3rd party services:
Support for other chatbot analytics tools planned.
npm install chatbot-analytics --save
First include this module and initialize it with your Google Analytics tracking ID.
const ChatbotAnalytics = require('chatbot-analytics');
Then, simply track an event like this:
// Instantiate:
const ca = new ChatbotAnalytics({ga: {trackingId: 'YOUR_GA_TRACKING_ID'}});
// Send an event:
ca.trackEvent('[user_id_here]', '[category]', '[action]');
// Send an event (with additional paramters):
ca.trackEvent('[user_id_here]', '[category]', '[action]', '[label]', null, {locale: 'en'});
All possible options that can be passed in the constructor:
{
logging: my_logger, // Something like console.log or logger.debug
ga: { // Enable Google Analytics
trackingId: 'YOUR_GA_TRACKING_ID', // The tracking ID (GA property ID)
debug: true // Enable GA debug mode?
}
}
All mentions of Google Analytics and its use in this project are copyright of Google. Google does not endorse this project in any way.