Created
May 24, 2021 13:26
-
-
Save iswanj/7e97e1f1db3a5f823b2670249bb60444 to your computer and use it in GitHub Desktop.
Tracking Custom mixpanel events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { View, Text } from 'react-native'; | |
import {Button} from 'components'; | |
import {useMixpanel} from 'provider/MixpanelProvider'; // import useMixpanel hooks | |
const MyComponent = () => { | |
const mixpanel = useMixpanel(); // put this code top of your functional component | |
const handleTrack = () => { | |
// here you can use any mixpanel methods | |
// e.g. | |
// mixpanel.timeEvent("Image Upload"); | |
// mixpanel.track("Image Upload"); | |
// mixpanel.registerSuperProperties({'Plan': 'Mega', 'Cost': '2000'}); | |
// mixpanel.clearSuperProperties(); | |
// mixpanel.identify("13791"); | |
// mixpanel.alias('new_id', 'existing_id'); | |
mixpanel.track('Clicked Track me button'); | |
} | |
return ( | |
<View> | |
<Text>My Component</Text> | |
<Button onPress={handleTrack}><Text>Track me</Text></Button> | |
</View> | |
) | |
}; | |
export default MyComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment