You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to the official Mixpanel React Native library.
20
21
The Mixpanel React Native library is an open-source project, and we'd love to see your contributions!
21
22
We'd also love for you to come and work with us! Check out **[Jobs](https://mixpanel.com/jobs/#openings)** for details
22
23
23
-
# Quick Start Guide
24
+
##Quick Start Guide
24
25
25
26
Mixpanel's React Native SDK is a wrapper around Mixpanel’s native iOS and Android SDKs and it supports offline tracking. Check out our **[official documentation](https://developer.mixpanel.com/docs/react-native)** for more in depth information on installing and using Mixpanel on React Native.
26
27
27
28
<aname="installation"></a>
28
-
##Installation
29
-
### Prerequisites
29
+
### 1. Install Mixpanel
30
+
####Prerequisites
30
31
- React Native v0.6+
31
32
-[Setup development environment for React Native](https://reactnative.dev/docs/environment-setup)
32
-
### Steps
33
+
####Steps
33
34
1. Under your app's root directory, install Mixpanel React Native SDK
34
35
```npm install mixpanel-react-native```
35
36
2. Under your application's ios folder, run
36
37
```pod install```
37
-
Please note: You don't need to update your Podfile to add Mixpanel manually.
38
+
Please note: You do not need to update your Podfile to add Mixpanel.
38
39
3. For Xcode 12.5+, there is a known compile issue, please refer to this **[workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)**.
39
40
40
41
41
-
## Integration
42
-
### Initialization
42
+
### 2. Initialize Mixpanel
43
43
To start tracking with the library you must first initialize with your project token. To initialize the library, first add `import { Mixpanel }` and call `Mixpanel.init(token)` with your project token as it's argument.
44
44
```js
45
45
import { Mixpanel } from'mixpanel-react-native';
@@ -56,19 +56,50 @@ class YourClass extends React.Component {
56
56
...
57
57
```
58
58
Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
59
-
### Tracking
60
-
Once you've initialized the library, Mixpanel will <a href="https://mixpanel.com/help/questions/articles/which-common-mobile-events-can-mixpanel-collect-on-my-behalf-automatically" target="_blank">automatically collect common mobile events</a>. You can enable/ disable automatic collection through your <a href="https://mixpanel.com/help/questions/articles/how-do-i-enable-common-mobile-events-if-i-have-already-implemented-mixpanel" target="_blank">project settings</a>.
61
-
With the `mixpanel` object created in [the last step](#integration) a call to `track` is all you need to send additional events to Mixpanel.
59
+
### 3. Send Data
60
+
Let's get started by sending event data. You can send an event from anywhere in your application. Better understand user behavior by storing details that are specific to the event (properties). After initializing the library, Mixpanel will [automatically collect common mobile events](https://mixpanel.com/help/questions/articles/which-common-mobile-events-can-mixpanel-collect-on-my-behalf-automatically). You can enable/disable automatic collection through your project settings. Also, Mixpanel automatically tracks some properties by default; [learn more](https://help.mixpanel.com/hc/en-us/articles/115004613766-Default-Properties-Collected-by-Mixpanel).
You're done! You've successfully integrated the Mixpanel React Native SDK into your app. To stay up to speed on important SDK releases and updates, star or watch our repository on [Github](https://github.com/mixpanel/mixpanel-react-native).
69
-
67
+
In addition to event data, you can also send [user profile data](https://developer.mixpanel.com/docs/react-native#storing-user-profiles). We recommend this after completing the quickstart guide.
68
+
### 4. Check for Success
69
+
[Open up Live View in Mixpanel](http://mixpanel.com/report/live) to view incoming events.
70
+
Once data hits our API, it generally takes ~60 seconds for it to be processed, stored, and queryable in your project.
70
71
<a name="i-want-to-know-more"></a>
71
-
# I want to know more!
72
+
73
+
## FAQ
74
+
**I want to stop tracking an event/event property in Mixpanel. Is that possible?**
75
+
Yes, in Lexicon, you can intercept and drop incoming events or properties. Mixpanel won’t store any new data for the event or property you select to drop. [See this article for more information](https://help.mixpanel.com/hc/en-us/articles/360001307806#dropping-events-and-properties).
76
+
77
+
**I have a test user I would like to opt out of tracking. How do I do that?**
78
+
Mixpanel’s client-side tracking library contains the [optOutTracking()](https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#optOutTracking) method, which will set the user’s local opt-out state to “true” and will prevent data from being sent from a user’s device. More detailed instructions can be found in the section, [Opting users out of tracking](https://developer.mixpanel.com/docs/react-native#opting-users-out-of-tracking).
79
+
80
+
**Why aren't my events showing up?**
81
+
To preserve battery life and customer bandwidth, the Mixpanel library doesn't send the events you record immediately. Instead, it sends batches to the Mixpanel servers every 60 seconds while your application is running, as well as when the application transitions to the background. You can call [flush()](https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#flush) manually if you want to force a flush at a particular moment.
82
+
83
+
```
84
+
mixpanel.flush();
85
+
86
+
```
87
+
88
+
If your events are still not showing up after 60 seconds, check if you have opted out of tracking. You can also enable Mixpanel debugging and logging, it allows you to see the debug output from the Mixpanel library. To enable it, call [setLoggingEnabled](https://mixpanel.github.io/mixpanel-swift/Classes/MixpanelInstance.html#/s:8Mixpanel0A8InstanceC14loggingEnabledSbvp) to true, then run your iOS project with Xcode or android project with Android Studio. The logs should be available in the console.
89
+
90
+
```
91
+
mixpanel.setLoggingEnabled(true);
92
+
93
+
```
94
+
95
+
**Starting with iOS 14.5, do I need to request the user’s permission through the AppTrackingTransparency framework to use Mixpanel?**
96
+
No, Mixpanel does not use IDFA so it does not require user permission through the AppTrackingTransparency(ATT) framework.
97
+
98
+
**If I use Mixpanel, how do I answer app privacy questions for the App Store?**
99
+
Please refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details/)
100
+
101
+
102
+
## I want to know more!
72
103
73
104
No worries, here are some links that you will find useful:
0 commit comments