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
Copy file name to clipboardExpand all lines: src/connections/sources/catalog/libraries/mobile/kotlin-android/destination-plugins/mixpanel-kotlin-android.md
[Mixpanel](https://mixpanel.com/?utm_source=segmentio&utm_medium=docs&utm_campaign=partners){:target="_blank”} is an event-tracking and segmentation platform for your web and mobile apps. By analyzing the actions your users perform, you can gain a better understanding to drive retention, engagement, and conversion. The client-side Mixpanel Destination code is open-source.
6
+
[Mixpanel](https://mixpanel.com/?utm_source=segmentio&utm_medium=docs&utm_campaign=partners){:target="\_blank”} is an event-tracking and segmentation platform for your web and mobile apps. By analyzing the actions your users perform, you can gain a better understanding to drive retention, engagement, and conversion. The client-side Mixpanel Destination code is open-source.
7
7
8
-
Segment's Mixpanel destination plugin code is open source and [available on GitHub](https://github.com/segment-integrations/analytics-kotlin-mixpanel){:target="_blank"}.
8
+
Segment's Mixpanel destination plugin code is open source and [available on GitHub](https://github.com/segment-integrations/analytics-kotlin-mixpanel){:target="\_blank"}.
9
9
10
10
## Getting Started
11
11
12
-
13
-
14
12
1. From the Segment app Destinations page click on **Add Destination**.
15
13
2. Search for Mixpanel in the Destinations Catalog and confirm the Source to connect to.
16
14
3. Copy your Mixpanel "API Secret" and "Token", and paste them into the Connection Settings in Segment.
@@ -30,11 +28,9 @@ Or the following for Kotlin DSL
The first thing you'll want to do is to identify your users so Mixpanel knows who they are. You'll use the Identify method to accomplish this which takes the unique `userId` of a user and any `traits` you know about them.
68
64
69
65
> info ""
70
-
> **Important:** Mixpanel used to require that you call `alias` in all libraries to connect anonymous visitors to identified users. However, with the release of Mixpanel's new [Identity Merge feature](https://help.mixpanel.com/hc/en-us/articles/360039133851#enable-id-merge){:target="_blank"} this is no longer necessary. To enable ID Merge, go to your Mixpanel Settings Dashboard, navigate to **Project Settings > Identity Merge** and enable the setting from that screen. If you are _not_ using this setting, use the instructions below.
71
-
66
+
> **Important:** Mixpanel used to require that you call `alias` in all libraries to connect anonymous visitors to identified users. However, with the release of Mixpanel's new [Identity Merge feature](https://help.mixpanel.com/hc/en-us/articles/360039133851#enable-id-merge){:target="_blank"} this is no longer necessary. To enable ID Merge, go to your Mixpanel Settings Dashboard, navigate to **Project Settings > Identity Merge** and enable the setting from that screen. If you are \_not_ using this setting, use the instructions below.
72
67
73
68
As soon as you have a `userId` for a visitor that was previously anonymous you'll need to [`alias`](/docs/connections/spec/alias/) their old anonymous `id` to the new `userId`. In Mixpanel only **one** anonymous user history can be merged to **one** identified user. For that reason you should only call `alias` once, right after a user registered, but before the first `identify`.
74
69
75
-
When you call the Identify method from the client in either a browser using Analytics.js or one a mobile SDKs, several things occur: Segment recognizes and translates the [special traits](/docs/connections/spec/identify/#traits) so that they fit the expectations of Mixpanel's API. The table below shows the mappings. Pass the key on the left and Segment transforms it to the key on the right before sending to Mixpanel.
70
+
When you call the Identify method from the client in either a browser using Analytics.js or one a mobile SDKs, several things occur: Segment recognizes and translates the [special traits](/docs/connections/spec/identify/#traits) so that they fit the expectations of Mixpanel's API. The table below shows the mappings. Pass the key on the left and Segment transforms it to the key on the right before sending to Mixpanel.
76
71
77
72
<table>
78
73
<tr>
@@ -117,7 +112,7 @@ Group calls are sent to Mixpanel if, **and only if**,
117
112
118
113
1. The Group Identifier Traits setting has one or more traits saved in the destination settings for Mixpanel.
119
114

120
-
2. You have created a group key of the same name in your Mixpanel [project settings](https://help.mixpanel.com/hc/en-us/articles/360025333632-Group-Analytics#implementation){:target="_blank"}.
115
+
2. You have created a group key of the same name in your Mixpanel [project settings](https://help.mixpanel.com/hc/en-us/articles/360025333632-Group-Analytics#implementation){:target="\_blank"}.
121
116
3. A Group trait with the same name as one of the configured Group Identifier Traits is sent with the group call.
Mixpanel supports multiple definitions of groups. For more information see [Mixpanel's Group Analytics documentation](https://help.mixpanel.com/hc/en-us/articles/360025333632-Group-Analytics){:target="_blank"}.
126
+
Mixpanel supports multiple definitions of groups. For more information see [Mixpanel's Group Analytics documentation](https://help.mixpanel.com/hc/en-us/articles/360025333632-Group-Analytics){:target="\_blank"}.
132
127
133
128
If the group call **does not** have a group trait that matches the Group Identifier Traits setting, then the event will be ignored.
Because Mixpanel is an event tracking analytics tool, you'll want to [`track`](/docs/connections/spec/track/) your user's actions. The more useful events you [`track`](/docs/connections/spec/track/), the better Mixpanel becomes.
161
157
162
158
You should use the [`track`](/docs/connections/spec/track/) method to accomplish this. The Segment [`track`](/docs/connections/spec/track/) method maps events and event properties directly to Mixpanel events and event properties.
@@ -173,22 +169,21 @@ There are two strings to avoid when naming event properties that will be sent to
173
169
174
170
Previously, Segment set all traits and properties as both Super Properties and People Properties (If you had Mixpanel People enabled). Now Mixpanel allows you to segment your reports by both People Properties and Super Properties. To give you better precision and control over what property or trait gets set as a Super Property or People Property, you can disable **Set All Traits as Super Properties or People Properties By Default** and pass in the properties or traits that you want to send to Mixpanel as People or Super Properties as shown below. Segment passes through all of Mixpanel's special traits as People Properties so you only need to add the ones that aren't on [this list](#group-using-device-mode).
175
171
176
-
177
-

172
+

178
173
179
174
### Incrementing events
180
175
181
176
You don't need to add extra code to increment event counts for Mixpanel people, as long as they are "known users". Supply the events that should be incremented.
You can find this in the **Advanced Options** of your Mixpanel settings on your Segment Destinations page.
186
181
187
182
For each event name listed, Segment calls Mixpanel `increment`, and set a user trait of `Last + {{ event.name }}`.
188
183
189
184
For example, if you add **Logged In** to the list of increment events, Segment increments a user trait called **Logged In** and set a trait called **Last Logged In** with the current date and time.
190
185
191
-
If you'd like to add an increment for viewing a specific page or screen, ensure you have the setting "Track Named Pages" selected and use the dynamically generated event name under "Events to Increment in People." For example, `.page('Signup')` would translate to "*Viewed* Signup *Page*" and `.screen('Listing')` would translate to "*Viewed* Listing *Screen*".
186
+
If you'd like to add an increment for viewing a specific page or screen, ensure you have the setting "Track Named Pages" selected and use the dynamically generated event name under "Events to Increment in People." For example, `.page('Signup')` would translate to "_Viewed_ Signup _Page_" and `.screen('Listing')` would translate to "_Viewed_ Listing _Screen_".
192
187
193
188
Remember, Segment sends one event per `page` call.
194
189
@@ -232,4 +227,4 @@ If you're testing in Xcode remember you must first background the app, then the
232
227
Push notifications are only available for projects bundling the Segment-Mixpanel SDK.
233
228
234
229
> info ""
235
-
> Set up your push notification handlers by calling into native Mixpanel methods. You can read more about how to approach this in [Android] (/docs/connections/sources/catalog/libraries/mobile/android/android-faqs/#how-can-i-use-a-destination-specific-feature)
230
+
> Set up your push notification handlers by calling into native Mixpanel methods. You can read more about how to approach this in [Android] (/docs/connections/sources/catalog/libraries/mobile/android/android-faqs/#how-can-i-use-a-destination-specific-feature)
Copy file name to clipboardExpand all lines: src/connections/sources/catalog/libraries/mobile/kotlin-android/kotlin-android-faq.md
+24-20Lines changed: 24 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ The core Segment SDK is extremely lightweight. The JAR weighs in at 12.3KB.
30
30
## How should I configure Proguard?
31
31
32
32
For the Segment SDKs, you can add the following snippet to your Proguard configuration:
33
+
33
34
```
34
35
- keep class com.segment.analytics.** { *; }
35
36
- keep class androidx.lifecycle.DefaultLifecycleObserver
@@ -49,42 +50,45 @@ Yes. Please refer to the [Java Compatibility](https://github.com/segmentio/analy
49
50
50
51
If you're on a version prior to `1.10.4`, the SDK internally uses a number of Java 8 language APIs through desugaring (see [Java 8+ API](https://developer.android.com/studio/write/java8-support#library-desugaring) desugaring support). Please make sure your project either uses Android Gradle plugin 4.0.0 or higher, has a minimum API level of 26, or is upgraded to the latest SDK.
51
52
52
-
53
53
## My deeplinks are not tracked?
54
54
55
-
56
55
While Analytics Kotlin will automatically track deep links that open your app when the `trackDeepLinks` Configuration property is set to `true`. There are some situations when the app is already open that could cause a deep link open event to be missed.
57
56
58
57
The `openUrl` function allows you to manually track that a deep link has opened your app while your app was already open:
59
58
59
+
```
60
+
override fun onNewIntent(intent: Intent?) {
61
+
super.onNewIntent(intent)
62
+
63
+
// Add a deep-link opened event manually.
64
+
// This is necessary when your Activity has a android:launchMode of
65
+
// 'singleInstance', 'singleInstancePerTask', 'singleTop', or any other mode
66
+
// that will re-use an existing Activity instead of creating a new instance.
67
+
// The Analytics SDK automatically identifies when you app is started from
68
+
// a deep link if the Activity is created, but not if it is re-used. Therefore
69
+
// we have to add this code to manually capture the Deep Link info.
70
+
71
+
val referrer = "unknown"
72
+
analytics.trackDeepLinkOpen(referrer, intent)
73
+
}
74
+
```
60
75
61
-
override fun onNewIntent(intent: Intent?) {
62
-
super.onNewIntent(intent)
63
-
64
-
// Add a deep-link opened event manually.
65
-
// This is necessary when your Activity has a android:launchMode of
66
-
// 'singleInstance', 'singleInstancePerTask', 'singleTop', or any other mode
67
-
// that will re-use an existing Activity instead of creating a new instance.
68
-
// The Analytics SDK automatically identifies when you app is started from
69
-
// a deep link if the Activity is created, but not if it is re-used. Therefore
70
-
// we have to add this code to manually capture the Deep Link info.
71
-
72
-
val referrer = "unknown"
73
-
analytics.trackDeepLinkOpen(referrer, intent)
74
-
}
75
-
76
-
Note: Due to the way deep links are handled in Android, we can not know the referrer when a deep link causes `onNewIntent()` to be fired instead of `onCreate()`.
76
+
Note: Due to the way deep links are handled in Android, we can not know the referrer when a deep link causes `onNewIntent()` to be fired instead of `onCreate()`.
77
77
78
78
For a sample implementation see our [Kotlin Sample App](https://github.com/segmentio/analytics-kotlin/tree/main/samples/kotlin-android-app).
79
79
80
80
## Will I still see device-mode integrations listed as `false` in the integrations object?
81
+
81
82
When you successfully package a plugin in device-mode, you will no longer see the integration listed as `false` in the integrations object for a Segment event. This logic is now packaged in the event metadata, and is not surfaced in the Segment debugger.
82
83
83
84
## What is the instanceId set in context?
84
-
The instanceId was introduced in [V 1.10.1](https://github.com/segmentio/analytics-kotlin/releases/tag/1.10.1){:target="_blank"} and correlates events to a particular instance of the client in a scenario when you might have multiple instances on a single app.
85
+
86
+
The instanceId was introduced in [V 1.10.1](https://github.com/segmentio/analytics-kotlin/releases/tag/1.10.1){:target="\_blank"} and correlates events to a particular instance of the client in a scenario when you might have multiple instances on a single app.
85
87
86
88
## How should I configure my proxy URL?
89
+
87
90
To proxy events to Segment's API, you can configure your proxy URL via the `requestFactory` setting:
When proxying your events, you must forward the batched events to `https://api.segment.io/v1/b`. The `https://api.segment.io/v1/batch` endpoint is reserved for events arriving from server side sending, and proxying to that endpoint for your mobile events may result in unexpected behavior.
111
+
When proxying your events, you must forward the batched events to `https://api.segment.io/v1/b`. The `https://api.segment.io/v1/batch` endpoint is reserved for events arriving from server side sending, and proxying to that endpoint for your mobile events may result in unexpected behavior.
0 commit comments