# Adjust

Set attributes and trigger automations from Adjust.

Adjust provides mobile measurement capabilities, helping you learn about your audience. This integration helps you take advantage of your audience data from Adjust in Airship, either to segment your audience or to trigger automated messages.

* Set attributes on your Airship audience, using information from Adjust to personalize messages and refine your audience. You must set up attributes in Airship to receive this information before you can set attributes from Adjust.<!-- link here -->
* Send custom events from Adjust into Airship, utilizing your audience information from Adjust to personalize and trigger automations and [Sequences](https://www.airship.com/docs/reference/glossary/#sequence).

## Adjust Integration Requirements

* **Accounts**
   1. Adjust
   1. Airship — Must include messaging
* **Airship project**
   * The Airship SDK must use the same user identity as the Adjust SDK.

## Configuring the Adjust Integration 

In Airship:

1. Next to your project name, select the dropdown menu (
), then **Settings**.
1. Under **Project settings**, select **Partner Integrations**.
1. Select **Adjust**.
1. Select **Configure** for the inbound integration and follow the onscreen instructions to:
   * Create [Attributes](https://www.airship.com/docs/reference/glossary/#attributes), [Custom Events](https://www.airship.com/docs/reference/glossary/#custom_event), and an authentication token for your project. Adjust uses the token to communicate with your project in Airship
   * Add Airship as a partner in Adjust.

## SDK Setup

To use the Adjust integration, you must add Adjust dependencies and associate Airship Channel IDs with Adjust's `airship_channel_id` callback parameter.

### Android Setup
For more information, see the [Adjust Android SDK Docs](https://github.com/adjust/android_sdk#quick-start-1).

1. **Add dependencies to `build.gradle`**

```gradle
implementation 'com.adjust.sdk:adjust-android:4.22.0'
implementation 'com.android.installreferrer:installreferrer:1.1.2'
```

1. **Associate channel IDs with Adjust `airship_channel_id`**

```java
String channelId = Airship.getChannel().getId();
Adjust.addSessionPartnerParameter("airship_channel_id", channelId);
```


### iOS Setup
For iOS, you must add the Adjust dependency to your `Podfile` and then associate channel IDs with Adjust's `airship_channel_id` callback parameter. For more information, see the [Adjust iOS SDK Docs](https://github.com/adjust/ios_sdk#basic-integration).

**Add dependency to `Podfile`**

1. If this is your first time using CocoaPods, Install CocoaPods using `gem install cocoapods`. Otherwise, continue to Step 3.
1. Run `pod setup` to create a local CocoaPods spec mirror.
1. Create a `Podfile` in your Xcode project directory by running `pod init` in your terminal, edit the `Podfile` generated and add the dependency `pod 'Adjust', '~> 4.22.1'`.
1. Run `pod install` in your Xcode project directory. CocoaPods should download and install the added library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.

**Swift: Associate channel IDs with Adjust `airship_channel_id`**

```swift
let channelId = UAirship.channel()?.identifier
if (channelId != nil) {
 Adjust.addSessionPartnerParameter("airship_channel_id", value: channelId!)
}
```


**Objective-C: Associate channel IDs with Adjust `airship_channel_id`**

```objc
NSString *channelId = [UAirship channel].identifier;
[Adjust addSessionPartnerParameter:@"airship_channel_id" value:channelId];
```



## List of Attributes Received from Adjust

| Attribute Name  | Adjust parameter | Attribute ID  | Type  |
|---|---|---|---|
| Adjust Device ID  | `adid` |`adjust_device_id`  | Text  |
| Adjust Device City  | `city` |`adjust_device_city`  | Text  |
| Adjust Device Country Subdivision  | `country_subdivision` |  `adjust_device_country_subdivision` | Text  |
| Adjust Device Country Code  | `country` | `adjust_device_country_code` | Text  |
| Adjust Device Currency Code  | `currency` | `adjust_currency_code`  | Text  |
| Adjust Device Model Number  | `device_name` | `adjust_device_model_number`  | Text  |
| Adjust Google Play Store Store Ad ID MD5 Hash | `gps_adid_md5` | `adjust_gps_ad_id_md5`  | Text  |
| Adjust Google Play Store Ad ID  | `gps_adid` | `adjust_gps_ad_id`  | Text  |
| Adjust Device IP Address  | `ip_address` | `adjust_device_ip_address`  | Text  |
| Adjust Is Reattributed  | `is_reattributed` | `adjust_is_reattributed`  | Number<sup>1</sup>  |
| Adjust Device ISP  | `isp` | `adjust_device_isp`  | Text  |
| Adjust Device Language Code  | `language` | `adjust_device_language_code` | Text  |
| Adjust Last Session Time in Seconds  | `last_time_spent` | `adjust_last_time_spent`  | Number  |
| Adjust Lifetime Session Count  | `lifetime_session_count` |`adjust_lifetime_session_count`  | Number  |
| Adjust Attribution Method  | `match_type` | `adjust_attribution_method`  | Text  |
| Adjust OAID Device ID MD5 Hash  | `oaid_md5` | `adjust_oaid_device_id_md5`  | Text  |
| Adjust OAID Device ID  | `oaid` | `adjust_oaid_device_id`  | Text  |
| Adjust Device Postal Code  | `postal_code` | `adjust_device_postal_code`  | Text  |
| Adjust Random Device Reference Tag  | `reftag` | `adjust_reftag`  | Text  |
| Adjust Device Region Code  | `region` | `adjust_device_region_code`  | Text  |
| Adjust Reporting Currency  | `reporting_currency` | `adjust_reporting_currency`  | Text  |
| Adjust SDK Version  | `sdk_version` | `adjust_sdk_version`  | Text  |
| Adjust Session Count  | `session_count` | `adjust_session_count`  | Number  |
| Adjust Current Session Time in Seconds  | `time_spent` | `adjust_time_spent`  | Number  |
| Adjust Tracking Enabled  | `tracking_enabled` | `adjust_tracking_enabled`  | Number<sup>1</sup>  |
| Adjust Tracking Limited  | `tracking_limited` | `adjust_tracking_limited`  | Number<sup>1</sup>  |
| Adjust Web Unique ID  | `web_uuid` | `adjust_web_uuid`  | Text  |
| Adjust Network Name   | `network_name` | `adjust_network_name`  | Text  |
| Adjust Campaign Name  | `campaign_name` | `adjust_campaign_name`  | Text  |



<sup>1</sup> Value is either 0 (false) or 1 (true/enabled).

### Airship Channel Example with Adjust Attributes

Attributes appear in an `attributes` object on the channel. Attributes won't appear on channels until set from Adjust.

**Airship channel example**

```json
{
   "channel_id": "516a818b-b57e-4a35-b7ad-41c6ef447364",
   "device_type": "android",
   "installed": true,
   "opt_in": true,
   "background": true,
   "push_address": "<push_address>",
   "created": "2019-07-31T00:10:34",
   "last_registration": "2020-08-17T08:11:46",
   "alias": null,
   "tags": [],
   "tag_groups": {
      "group": [
         "tags"
      ]
   },
   "device_attributes": {
      "ua_device_os": "10",
      "ua_country": "US",
      "ua_device_model": "SM-G973U",
      "ua_local_tz": "America/Los_Angeles",
      "ua_app_version": "<version>",
      "ua_location_settings": "true",
      "ua_language": "en",
      "ua_sdk_version": "13.2.0",
      "ua_carrier": "Verizon "
   },
   "attributes": {
      "adjust_lifetime_session_count": 45,
      "adjust_device_postal_code": "97209",
      "adjust_device_region_code": "US",
   }
}
```


## Custom Event Properties from Adjust

Events from Adjust are of the `Custom` type, with the `body.name` of the event representing the Adjust event type — `install`, `rejected install`, `session`, `in-app event`, `reattribution`, or `rejected reattribution`. Properties from Adjust appear in the `body.properties` object.

| Custom Event Property  | Description  |
|---|---|
| `adjust_attribution_method`  | Attribution method  |
| `partner_parameters`  | Custom partner parameters collected by the Adjust SDK or S2S request and transmitted to third party providers via postbacks  |
| `reporting_revenue`  | Revenue, as reported in the Adjust Dashboard, in whole currency units  |
| `revenue_float`  | Revenue, as sent from Adjust SDK, in whole currency units  |
| `revenue_usd_cents`  | Revenue, in US cents  |
| `revenue_usd`  | Revenue, in US dollars  |
| `revenue`  | Revenue, as sent from Adjust SDK in cents  |
| `adjust_network_name`  | Network name  |
| `adjust_campaign_name`  | Campaign name  |


**Sample Adjust Custom Event**

```json
{
    "id": "aae70da5-a276-4dd4-a11e-f5b5796a52f1",
    "offset": "1000000000780",
    "occurred": "2020-08-17T22:37:53.000Z",
    "processed": "2020-08-17T22:40:35.337Z",
    "device": {
        "ios_channel": "c014a2ed-4c30-4f6d-a9b3-e2ba7a01b45c",
        "channel": "c014a2ed-4c30-4f6d-a9b3-e2ba7a01b45c",
        "device_type": "IOS",
        "attributes": {
            "locale_variant": "",
            "app_version": "1.0",
            "device_model": "x86_64",
            "app_package_name": "com.urbanairship.partner.adjust",
            "iana_timezone": "America/Los_Angeles",
            "push_opt_in": "false",
            "locale_country_code": "US",
            "device_os": "13.0",
            "locale_timezone": "-25200",
            "locale_language_code": "en",
            "location_enabled": "false",
            "background_push_enabled": "false",
            "ua_sdk_version": "13.2.0",
            "location_permission": "UNPROMPTED"
        }
    },
    "body": {
        "name": "session",
        "session_id": "c014a2ed-4c30-4f6d-a9b3-e2ba7a01b45c",
        "source": "API",
        "properties": {
            "adjust_attribution_method": "",
            "partner_parameters": "",
            "reporting_revenue": 25,
            "revenue_float": 25.00,
            "revenue_usd_cents": 2500,
            "revenue_usd": 25,
            "revenue": 2500,
            "adjust_network_name": "meta",
            "adjust_campaign_name": "Spring 2020"
        }
    },
    "type": "CUSTOM"
}
```
