@xtreamsrl/react-analytics-mixpanel
v0.2.1
Published
This package exposes an implementation of the analytics manager that uses [mixpanel](https://mixpanel.com/).
Downloads
160
Readme
@xtreamsrl/react-analytics-mixpanel
This package exposes an implementation of the analytics manager that uses mixpanel.
Installation
npm install @xtreamsrl/react-analytics-mixpanel
Usage
In order to use Mixpanel as the analytics manager, you need a simple configuration step:
configureAnalytics(
new Mixpanel(config.mixpanelTrackingToken)
);
Substantially, you need to pass the Mixpanel tracking token to the Mixpanel constructor.
Given that usually the tracking token is retrieved from the environment variables, you can use the config
object to access it after having added the variable to the .env
file.
In case you have a pipeline that injects the environment variables, remember to add the variable also there!
Another useful notion to mention is related to conditional tracking. In some cases, you might want to track events only in certain environments. To achieve this, you can use another environment variable to enable or disable the tracking. This scenario would lead to the following configuration:
configureAnalytics(
config.enableMixpanelTracking
? new Mixpanel(config.mixpanelTrackingToken)
: new DummyAnalyticsManager(),
);
For more details on how to use the library read the react-analytics README.