# Setting up Adobe Analytics for Mobile

Segment supports Adobe Analytics Mobile Services. With Segment, you don't need to package Adobe Analytics SDKs to use Adobe Analytics Mobile Services features.

To learn more about Segment's mobile libraries, see the [iOS](/docs/segment/connections/sources/catalog/libraries/mobile/ios) and [Android](/docs/segment/connections/sources/catalog/libraries/mobile/android) technical docs.

## Setting Up the Mobile SDKs

Before you start sending data from your mobile application to Adobe Analytics, you must first finish the following set up steps:

* First, enable the Segment-Adobe Analytics destination from in your Segment workspace.
* From your Adobe Mobile Services dashboard, check and customize the settings on the "Manage App Settings" tab.
* Download these settings as the `ADBMobileConfig.json` file by clicking the **Config JSON** link at the bottom of the same tab. Follow the instructions in Adobe's [Configuration documentation](https://developer.adobe.com/client-sdks/home/base/mobile-core/configuration/).
* Finally, follow the instructions below for each mobile environment to bundle Segment's Adobe Analytics SDK in your project.

> \[!NOTE]
>
> Mobile implementations use the `ADBMobileConfig.json` file to store the settings that you would otherwise enter in the Adobe Analytics destination settings in the Segment app. You can change these settings from the Manage App Settings tab in your Adobe Mobile Services dashboard, and can download the file from that same tab. This file includes the Report Suite ID, Timestamp Option, Tracking Server Secure URL, Tracking Server URL, and Use Secure URL for Server-side settings.

#### For Android

```java
compile 'com.segment.analytics.android.integrations:adobeanalytics:+'
```

After you add the dependency, register the integration with the Segment SDK. To do this, import the Adobe Analytics integration:

```java
import com.segment.analytics.android.integrations.adobeanalytics.AdobeIntegration;
```

Then add the following line:

```java
analytics = new Analytics.Builder(this, "write_key")
                .use(AdobeIntegration.FACTORY)
                .build();
```

> \[!NOTE]
>
> **Note:** If you're working on Android, be sure to add these permissions to your `AndroidManifest.xml`:

```xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
```

You can see the [Android SDK changelog](https://github.com/segment-integrations/analytics-android-integration-adobe-analytics/blob/master/CHANGELOG.md) in the open-source repository for information about specific versions of the Android Adobe Analytics SDK.

#### For iOS

```objc
pod 'Segment-Adobe-Analytics'
```

You can see the [iOS SDK changelog](https://github.com/segment-integrations/analytics-ios-integration-adobe-analytics/blob/master/Changelog.md) in the open-source repository for information about specific versions of the iOS Adobe Analytics SDK.

## Sending Data to Adobe analytics

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 `eVars` or `props`, since you'll have to do this in both the Segment settings UI and your Adobe Mobile Services dashboard.

## Sending Events

You can map Segment events in your `Events V2` settings to any event variable you already defined in your Adobe Analytics Mobile Services dashboard.

> \[!WARNING]
>
> **Note**: Do not use the deprecated `Events` settings. These no longer forward events to Adobe.

Here's an example of how you might map Segment events to Adobe Analytics events connected in device mode:

![Adobe Analytics settings in Segment with 'color' mapping to 'myapp.adobe.color' under the Context Data Variables tab.](https://docs-resources.prod.twilio.com/b212f1bf1c2b781499fb3676a37b7d17d0080ff55833221155854bc966d87ce9.png)

Here's an example of how you would implement the same mapping in Adobe's Mobile Services Dashboard:

![Adobe Analyitcs Custom Metrics tab showing the metric for 'Clicked A Button' defined.](https://docs-resources.prod.twilio.com/b834ff239e9c9865d92cc8d2e43485ec6dbfeec94cf8328967bcd4c90e620f4a.png)

## Sending Custom Properties

You can use the `Context Data Variables` settings to map Segment `properties` to any context data variable defined in your Adobe Analytics Mobile Services dashboard. This includes both Adobe `props` and `eVars`. You can see a list of the Adobe variable types in your Adobe Mobile Services dashboard.

![A screenshot of the Adobe Analytics settings page in Segment, with the Mappings section selected.](https://docs-resources.prod.twilio.com/28c8c85f97abee40238f8899df78cdbb4d3303e73d8deaf237ebd49c1acc95a1.png)

Here's an example of how you would implement the same mapping in Adobe's Mobile Services Dashboard:

![The Custom Variables tab in Adobe's Mobile Services Dashboard showing prop1 variable named 'Color' with context data 'myapp.adobe.color'.](https://docs-resources.prod.twilio.com/c7aa93e7eb47d1c05a13308d8fc3212fa97e660e3589425b1638e84d4c735a69.png)

| **Segment Payload Field**                           | **iOS Mapping Notation**            | **Android Mapping Notation** |
| --------------------------------------------------- | ----------------------------------- | ---------------------------- |
| `anonymousId`                                       | `anonymousId`                       | `.anonymousId`               |
| `messageId`                                         | `messageId`                         | `.messageId`                 |
| `event`<br />`.track()` calls only                  | `event`                             | `.event`                     |
| `name`<br />`screen()` calls only                   | `name`                              | `.name`                      |
| `context.traits.key`                                | `traits.key`                        | `.context.traits.key`        |
| `context.key`                                       | `key`                               | `.context.key`               |
| `context.arrayKey.key`<br />ie. `context.device.id` | `arrayKey.key`<br />ie. `device.id` | `.context.arrayKey.key`      |
| `properties.key`                                    | `key`                               | `key`                        |

## Adobe Lifecycle events

Segment implements Adobe Lifecycle Events automatically - you don't have to enable any additional settings! Lifecycle events gather important information such as app launches, crashes, session length, and more. See the [list of all Adobe lifecycle metrics and dimensions](https://marketing.adobe.com/resources/help/en_US/mobile/android/metrics.html) to learn more.

## Identify on Mobile

When you make an Identify call, Segment sets the Adobe `visitorId` to the value of the user's Segment `userId`. The snippets below show what Segment does with this information, for iOS and Android.

## Identify on Android

```java
Config.setUserIdentifier("123");
```

## Identify on iOS

```objc
[ADBMobile setUserIdentifier:@"123"];
```

## Screen on Mobile

When you call `screen`, Segment sends an Adobe `trackState` event, and passes the screen name and any properties you mapped to Adobe, as context data values.

The snippets below show what Segment does with this information, for iOS and Android.

## Screen on Android

```java
Analytics.trackState("Home Screen", <properties mapped in contextData>);
```

## Screen on iOS

```objc
[self.ADBMobile trackState:@"Home Screen" data:<properties mapped in contextData>];
```

## Track on Mobile

When you call `track`, Segment sends an Adobe `trackAction` event, and passes your event name and any properties you mapped to Adobe, as context data values.
The snippets below show what Segment does with this information, for iOS and Android.

## Track on Android

```java
Analytics.trackEvent("Clicked A Button", <properties mapped in contextData>);
```

## Track on iOS

```objc
[ADBMobile trackAction:@"Clicked A Button" data:<properties mapped in contextData>];
```

## Reset on Mobile

Calling `reset` sets the user's `visitorId` to  `null`. `null` is Adobe's default `visitorId` value until you explicitly set it (by calling `identify`). The snippets below show what Segment does in the background.

## Reset on Android

```java
Config.setUserIdentifier(null);
```

## Reset on iOS

```objc
[ADBMobile trackingClearCurrentBeacon];
```

## Flush on Mobile

Calling `flush` immediately sends all locally queued events to Adobe. The snippets below show what Segment sends on Android and iOS.

## Flush on Android

```java
Analytics.sendQueuedHits();
```

## Flush on iOS

And on iOS:

```objc
[ADBMobile trackingSendQueuedHits];
```
