@smartpay/mixpanel
v1.0.9
Published
Mixpanel
Readme
Mixpanel
This module is an in-house minimalism for easily integrating Mixpanel across Consumer and Merchant projects
Usage
Initialization
- Pass a
tokenand super properties toMixpanel.initializein yourApp.tsx
Mixpanel.initialize({
token: process.env.REACT_APP_MIXPANEL_TOKEN || '',
superProps: {
Product: 'Checkout',
Platform: 'Web',
},
});urlToScreenprop is optional to easily define tracking screen name based on current url path
Track page view and duration
- Add
useTrackPageViewin your screen render method. By default, it will also track a duration the consumer stays on that screen.
const LoginScreen: FC<RouteComponentProps> = () => {
useTrackPageView();
return (
...
)
};Track actions
- Call
trackActionwith an item name of that element
Mixpanel.trackAction({
action: 'Click',
itemName: 'Submit',
});Track user idenfifer
- Call
setUserIDafter initalization with a unique identifier from the Backend
Register super properties
- Call
registerSuperPropertiesto have certain properties that you want to include with each event you send
Set user properties
- Call
setUserPropertiesto explore and segment users by who they are
