Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ To learn more about the `typewriter.yml` configuration format, see the [Configur

As mentioned in the [Best Practices](#best-practices) section above, Segment recommends that you only check in the `plan.json`, and not the generated clients, into your version control. Instead, Segment recommends building these clients as part of the build step for your application.

In your CI environment, this usually involves a step to build the Typewriter client. Make sure to build the production client before deploying the application, as explained in the [Tracking Plan Violation Handling](#tracking-plan-violation-handling) section below.
In your CI environment, this usually involves a step to build the Typewriter client. Make sure to build the production client before deploying the application, as explained in [Tracking Plan Violation Handling](/docs/protocols/apis-and-extensions/typewriter/#tracking-plan-violation-handling).

```yaml
# An example (simplified) CircleCI configuration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Adobe Analytics uses a slightly different approach to tracking than Segment, and

For example, if one of your end users dismissed a welcome dialog in your app, Segment would generate a `Welcome Dialog Dismissed` event with properties that contain the user ID (`user123`) and the dialog name (`welcome-dialog`), while Adobe Analytics would model the same action as a pageView with variables that represent the dialog name, visitorID, and the event name, and an eVar ("dismissed").

Both Segment and Adobe Analytics have recommended standard data for tracking events. Segment has [the Spec](/docs/connections/spec/), and Adobe uses predefined events. Segment automatically maps incoming event data and some product level properties to Adobe's predefined events, when the event data is in the correct Segment Ecommerce Spec](/docs/connections/spec/ecommerce/v2/) format. Video calls using the format described in this document are also automatically mapped. If you're using the Mobile SDKs, mobile lifecycle events are also automatically mapped. If you need to create Page and Track events that are outside the scope of the Ecommerce Spec, you need to map those in your Segment destinations settings UI.
Both Segment and Adobe Analytics have recommended standard data for tracking events. Segment has [the Spec](/docs/connections/spec/), and Adobe uses predefined events. Segment automatically maps incoming event data and some product level properties to Adobe's predefined events, when the event data is in the correct [Segment Ecommerce Spec](/docs/connections/spec/ecommerce/v2/) format. Video calls using the format described in this document are also automatically mapped. If you're using the Mobile SDKs, mobile lifecycle events are also automatically mapped. If you need to create Page and Track events that are outside the scope of the Ecommerce Spec, you need to map those in your Segment destinations settings UI.

Segment strongly recommends that you create a Tracking Plan for both your Segment and Adobe Analytics events before you send any events or properties to Adobe. This helps you map your Segment events to Adobe `events` and Segment properties to Adobe variables. If you decide to set up Adobe Analytics for mobile, you must set up this mapping in both the Segment settings and the Adobe Mobile Services dashboard, so it's good to stay consistent.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Just under your Analytics-Kotlin library setup, call `analytics.add(plugin = ...

Your events will now begin to flow to Braze in device mode.

# Identify
## Identify

> info "Tip"
> Add Segment's open-source [Middleware](https://github.com/segmentio/segment-braze-mobile-middleware) tool to optimize your integration. This tool limits [Data Point](https://www.braze.com/docs/user_guide/data_and_analytics/data_points/) use by debouncing duplicate identify() calls from Segment. For more information, see the project's [README](https://github.com/segmentio/segment-braze-mobile-middleware/blob/master/README.md#how-does-this-work).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ strat: kotlin-android

Segment's Mixpanel destination plugin code is open source and [available on GitHub](https://github.com/segment-integrations/analytics-kotlin-mixpanel){:target="_blank"}.

## Getting Started


## Getting started

1. From the Segment app Destinations page click on **Add Destination**.
2. Search for Mixpanel in the Destinations Catalog and confirm the Source to connect to.
Expand All @@ -30,11 +28,9 @@ Or the following for Kotlin DSL
implementation('com.segment.analytics.kotlin.destinations:mixpanel:<latest_version>')
```



## Using the Plugin in your App

Open the file where you setup and configure the Analytics-Kotlin library. Add this plugin to the list of imports.
Open the file where you setup and configure the Analytics-Kotlin library. Add this plugin to the list of imports.

```
import com.segment.analytics.kotlin.destinations.mixpanel.MixpanelDestination
Expand Down Expand Up @@ -67,12 +63,11 @@ analytics.identify("user-123", buildJsonObject {
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.

> info ""
> **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.

> **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.

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`.

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.
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.

<table>
<tr>
Expand Down Expand Up @@ -157,6 +152,7 @@ analytics.track("View Product", buildJsonObject {
put("productName" "Striped trousers")
});
```

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.

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.
Expand All @@ -171,16 +167,15 @@ There are two strings to avoid when naming event properties that will be sent to

### Explicitly Set People Properties and Super Properties

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).

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).

![mixpanel people properties list](images/mixpanelpeoplesuperprops.png)
![mixpanel people properties list](/docs/connections/destinations/catalog/mixpanel/images/mixpanelpeoplesuperprops.png)

### Incrementing events

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.

![mixpanel increment events list](images/mixpanelincrementinpeople.png)
![mixpanel increment events list](/docs/connections/destinations/catalog/mixpanel/images/mixpanelincrementinpeople.png)

You can find this in the **Advanced Options** of your Mixpanel settings on your Segment Destinations page.

Expand Down Expand Up @@ -232,4 +227,4 @@ If you're testing in Xcode remember you must first background the app, then the
Push notifications are only available for projects bundling the Segment-Mixpanel SDK.

> info ""
> 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)
> 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).
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The core Segment SDK is extremely lightweight. The JAR weighs in at 12.3KB.
## How should I configure Proguard?

For the Segment SDKs, you can add the following snippet to your Proguard configuration:

```
- keep class com.segment.analytics.** { *; }
- keep class androidx.lifecycle.DefaultLifecycleObserver
Expand All @@ -49,42 +50,45 @@ Yes. Please refer to the [Java Compatibility](https://github.com/segmentio/analy

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.


## My deeplinks are not tracked?


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.

The `openUrl` function allows you to manually track that a deep link has opened your app while your app was already open:

```
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)

// Add a deep-link opened event manually.
// This is necessary when your Activity has a android:launchMode of
// 'singleInstance', 'singleInstancePerTask', 'singleTop', or any other mode
// that will re-use an existing Activity instead of creating a new instance.
// The Analytics SDK automatically identifies when you app is started from
// a deep link if the Activity is created, but not if it is re-used. Therefore
// we have to add this code to manually capture the Deep Link info.

val referrer = "unknown"
analytics.trackDeepLinkOpen(referrer, intent)
}
```

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)

// Add a deep-link opened event manually.
// This is necessary when your Activity has a android:launchMode of
// 'singleInstance', 'singleInstancePerTask', 'singleTop', or any other mode
// that will re-use an existing Activity instead of creating a new instance.
// The Analytics SDK automatically identifies when you app is started from
// a deep link if the Activity is created, but not if it is re-used. Therefore
// we have to add this code to manually capture the Deep Link info.

val referrer = "unknown"
analytics.trackDeepLinkOpen(referrer, intent)
}

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()`.
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()`.

For a sample implementation see our [Kotlin Sample App](https://github.com/segmentio/analytics-kotlin/tree/main/samples/kotlin-android-app).

## Will I still see device-mode integrations listed as `false` in the integrations object?

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.

## What is the instanceId set in context?

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.

## How should I configure my proxy URL?

To proxy events to Segment's API, you can configure your proxy URL via the `requestFactory` setting:

```
Analytics(BuildConfig.SEGMENT_WRITE_KEY, androidContext()) {
trackApplicationLifecycleEvents = true
Expand All @@ -104,4 +108,4 @@ Analytics(BuildConfig.SEGMENT_WRITE_KEY, androidContext()) {
}
```

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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ To learn more about the `typewriter.yml` configuration format, see the [Configur

As mentioned in the [Best Practices](#best-practices) section above, Segment recommends that you only check in the `plan.json`, and not the generated clients, into your version control. Instead, Segment recommends building these clients as part of the build step for your application.

In your CI environment, this usually involves a step to build the Typewriter client. Make sure to build the production client before deploying the application, as explained in the [Tracking Plan Violation Handling](#tracking-plan-violation-handling) section below.
In your CI environment, this usually involves a step to build the Typewriter client. Make sure to build the production client before deploying the application, as explained in [Tracking Plan Violation Handling](/docs/protocols/apis-and-extensions/typewriter/#tracking-plan-violation-handling).

```yaml
# An example (simplified) CircleCI configuration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you're using a previous Segment mobile library such as Analytics-Android, fol
1. [Import Analytics-Kotlin](#1-import-analytics-kotlin)
2. [Upgrade your Destinations](#2-upgrade-your-destinations)
3. [Advanced: Upgrade your Middleware](#3-upgrade-middleware-to-plugins)
4. [Upgrade Notes](#4-upgrade-notes-changes-to-the-configuration-object)
4. [Upgrade Notes](#4-upgrade-notes)

## 1. Import Analytics-Kotlin

Expand Down
Loading
Loading