---
title: "Adjust"
description: "Kết nối Adjust với Adapty để theo dõi gói đăng ký và phân tích tốt hơn."
---

[Adjust](https://www.adjust.com/) là một trong những nền tảng đo lường di động (MMP) hàng đầu, thu thập và trình bày dữ liệu từ các chiến dịch marketing, giúp các công ty theo dõi hiệu quả chiến dịch của mình.

Adapty cung cấp bộ dữ liệu đầy đủ để bạn theo dõi [sự kiện gói đăng ký](events) từ các cửa hàng ở một nơi duy nhất. Với Adapty, bạn có thể dễ dàng nắm bắt hành vi của người dùng, hiểu sở thích của họ, và sử dụng thông tin đó để giao tiếp một cách có mục tiêu và hiệu quả. Vì vậy, tích hợp này cho phép bạn theo dõi sự kiện gói đăng ký trong Adjust và phân tích chính xác doanh thu mà các chiến dịch của bạn tạo ra.

Tích hợp giữa Adapty và Adjust hoạt động theo hai hướng chính.

1. **Adapty nhận dữ liệu attribution từ Adjust**  
   Sau khi thiết lập tích hợp Adjust, Adapty sẽ bắt đầu nhận dữ liệu attribution từ Adjust. Bạn có thể dễ dàng truy cập và xem dữ liệu này trên trang hồ sơ người dùng.

  
    <img src="/assets/shared/img/98769d9-CleanShot_2023-08-11_at_14.39.182x.webp"
    style={{
      border: '1px solid #727272', /* border width and color */
      width: '700px', /* image width */
      display: 'block', /* for alignment */
      margin: '0 auto' /* center alignment */
    }}
  />
  

2. **Adapty gửi sự kiện gói đăng ký đến Adjust**  
   Adapty có thể gửi tất cả sự kiện gói đăng ký đã được cấu hình trong tích hợp của bạn đến Adjust. Nhờ đó, bạn có thể theo dõi các sự kiện này trong Adjust dashboard. Tích hợp này rất hữu ích để đánh giá hiệu quả của các chiến dịch quảng cáo.

## Thiết lập tích hợp \{#set-up-integration\}

### Kết nối Adapty với Adjust \{#connect-adapty-to-adjust\}

1. Mở Adapty Dashboard và điều hướng đến [Integrations > Adjust](https://app.adapty.io/integrations/adjust).

2. Bật toggle ở đầu trang.

3. Điền vào các trường và thiết lập thông tin xác thực.

  
    <img src="/assets/shared/img/5064125-CleanShot_2023-08-11_at_14.43.382x.webp"
    style={{
      border: '1px solid #727272', /* border width and color */
      width: '700px', /* image width */
      display: 'block', /* for alignment */
      margin: '0 auto' /* center alignment */
    }}
  />
  

3. Nếu bạn đã bật xác thực OAuth trên nền tảng Adjust, bạn bắt buộc phải cung cấp **OAuth Token** trong quá trình tích hợp cho ứng dụng iOS và Android của mình.
4. Tiếp theo, cung cấp **app tokens** cho ứng dụng iOS và Android. Mở Adjust dashboard và bạn sẽ thấy danh sách ứng dụng của mình.

  
    <img src="/assets/shared/img/adjust-apps.webp"
    style={{
      border: '1px solid #727272', /* border width and color */
      width: '700px', /* image width */
      display: 'block', /* for alignment */
      margin: '0 auto' /* center alignment */
    }}
  />
  

  :::note
  Bạn có thể có các ứng dụng Adjust khác nhau cho iOS và Android, vì vậy trong Adapty có hai mục riêng biệt cho chúng. Nếu bạn chỉ có một ứng dụng Adjust, hãy điền cùng một thông tin.
  :::

5. Chọn ứng dụng từ danh sách và sao chép **App Token**. Dán token vào trường tương ứng trên Adapty dashboard.

  <img src="/assets/shared/img/adjust-token.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

### Cấu hình sự kiện và tags \{#configure-events-and-tags\}

Adjust hoạt động hơi khác so với các nền tảng khác. Bạn cần tạo sự kiện thủ công trong Adjust dashboard, lấy token sự kiện, rồi sao chép-dán chúng vào các sự kiện tương ứng trong Adapty.

Vì vậy, bước đầu tiên là tìm token sự kiện cho tất cả các sự kiện bạn muốn Adapty gửi. Để làm điều đó:

1. Trong Adjust dashboard, mở ứng dụng của bạn và chuyển sang tab **Events**.

  <img src="/assets/shared/img/adjust-events.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

1. Sao chép token sự kiện và dán vào Adapty. Phía dưới thông tin xác thực, có ba nhóm sự kiện bạn có thể gửi đến Adjust từ Adapty. Xem danh sách đầy đủ các sự kiện mà Adapty cung cấp [tại đây](events).

  <img src="/assets/shared/img/adjust-event-token.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

Adapty sẽ gửi sự kiện gói đăng ký đến Adjust thông qua tích hợp server-to-server, cho phép bạn xem tất cả sự kiện gói đăng ký trong Adjust dashboard và liên kết chúng với các chiến dịch thu hút người dùng.

:::important
Lưu ý những điều sau:

- Adjust không hỗ trợ sự kiện cũ hơn 58 ngày. Vì vậy, nếu bạn có sự kiện cũ hơn 58 ngày, Adapty vẫn sẽ gửi đến Adjust nhưng thời gian của sự kiện sẽ được thay thế bằng timestamp hiện tại.
- Adjust không hỗ trợ IPv6. Nếu bạn tắt tính năng thu thập IP trong SDK trong **App settings** hoặc khi kích hoạt SDK, chỉ có IPv6 phía backend được gửi đi và việc theo dõi có thể thất bại — hãy giữ tính năng thu thập IP của SDK được bật để đảm bảo sử dụng IPv4.

:::

### Kết nối ứng dụng với Adjust \{#connect-your-app-to-adjust\}

Sau khi hoàn thành các bước trên, hãy thêm hai phương thức sau vào ứng dụng. Chúng sẽ thiết lập kết nối giữa ứng dụng và Adjust:

1. **Để gửi dữ liệu gói đăng ký đến Adjust**: Truyền Adjust device ID vào phương thức SDK `setIntegrationIdentifier()`
2. **Để nhận dữ liệu attribution từ Adjust**: Cập nhật dữ liệu attribution bằng phương thức SDK `updateAttribution()`

Đối với Adjust phiên bản 5.0 trở lên, hãy sử dụng ví dụ sau:

<Tabs groupId="current-os" queryString>
<TabItem value="swift" label="iOS (Swift)" default>

```swift showLineNumbers
class AdjustModuleImplementation {
    func updateAdjustAdid() {
        Adjust.adid { adid in
            guard let adid else { return }
            // Adapty SDK 4.x
            Adapty.setIntegrationIdentifier(.adjustDeviceId(adid))
            // Adapty SDK 3.x
            Adapty.setIntegrationIdentifier(key: "adjust_device_id", value: adid)
        }
    }

    func updateAdjustAttribution() {
        Adjust.attribution { attribution in
            guard let attribution = attribution?.dictionary() else { return }
            // Adapty SDK 4.x
            Adapty.updateAttribution(attribution, source: .adjust)
            // Adapty SDK 3.x
            Adapty.updateAttribution(attribution, source: "adjust")
        }
    }
}
```

</TabItem>
<TabItem value="kotlin" label="Android (Kotlin)" default>

```kotlin showLineNumbers
Adjust.getAdid { adid ->
    if (adid == null) return@getAdid

    Adapty.setIntegrationIdentifier("adjust_device_id", adid) { error ->
        if (error != null) {
            // handle the error
        }
    }
}

Adjust.getAttribution { attribution ->
    if (attribution == null) return@getAttribution

    Adapty.updateAttribution(attribution, "adjust") { error ->
        // handle the error
    }
}
```

</TabItem>
<TabItem value="java" label="Android (Java)" default>

```java showLineNumbers
Adjust.getAdid(adid -> {
    if (adid == null) return;

    Adapty.setIntegrationIdentifier("adjust_device_id", adid, error -> {
        if (error != null) {
            // handle the error
        }
    });
});

Adjust.getAttribution(attribution -> {
    if (attribution == null) return;

    Adapty.updateAttribution(attribution, "adjust", error -> {
        // handle the error
    });
});
```

</TabItem>
<TabItem value="rn" label="React Native (TS)" default>

```typescript showLineNumbers

var adjustConfig = new AdjustConfig(appToken, environment);

// Before submiting Adjust config...
adjustConfig.setAttributionCallbackListener(attribution => {
  // Make sure Adapty SDK is activated at this point
  // You may want to lock this thread awaiting of `activate`
  adapty.updateAttribution(attribution, "adjust");
});

// ...
Adjust.create(adjustConfig);

Adjust.getAdid((adid) => {
  if (adid)
    adapty.setIntegrationIdentifier("adjust_device_id", adid);
});
```

</TabItem>

<TabItem value="flutter" label="Flutter" default>

```javascript showLineNumbers

try {
  final adid = await Adjust.getAdid();

  if (adid == null) {
    // handle the error
  }
  
  await Adapty().setIntegrationIdentifier(
    key: "adjust_device_id", 
    value: adid,
  );
    
  final attributionData = await Adjust.getAttribution();

  var attribution = Map<String, String>();

  if (attributionData.trackerToken != null) attribution['trackerToken'] = attributionData.trackerToken!;
  if (attributionData.trackerName != null) attribution['trackerName'] = attributionData.trackerName!;
  if (attributionData.network != null) attribution['network'] = attributionData.network!;
  if (attributionData.adgroup != null) attribution['adgroup'] = attributionData.adgroup!;
  if (attributionData.creative != null) attribution['creative'] = attributionData.creative!;
  if (attributionData.clickLabel != null) attribution['clickLabel'] = attributionData.clickLabel!;
  if (attributionData.costType != null) attribution['costType'] = attributionData.costType!;
  if (attributionData.costAmount != null) attribution['costAmount'] = attributionData.costAmount!.toString();
  if (attributionData.costCurrency != null) attribution['costCurrency'] = attributionData.costCurrency!;
  if (attributionData.fbInstallReferrer != null) attribution['fbInstallReferrer'] = attributionData.fbInstallReferrer!;

  await Adapty().updateAttribution(attribution, source: "adjust");
} on AdaptyError catch (adaptyError) {
  // handle the error
} catch (e) {
  // handle the error
}
```

</TabItem>

<TabItem value="unity" label="Unity" default>

```csharp showLineNumbers
// 1. To update ADID
Adjust.GetAdid((adid) => {
    if (adid == null) {
        // handle the error
        return;
    }

    Adapty.SetIntegrationIdentifier("adjust_device_id", adid, (error) => {
        if (error != null) {
            // handle the error
            return;
        }

    });
});

// 2. To update Attribution

// in your adjust configuration scope:
adjustConfig.AttributionChangedDelegate = AttributionChangedCallback;

public void AttributionChangedCallback(AdjustAttribution attributionData) {
    var attribution = new Dictionary<string, string>();

    if (attributionData.TrackerToken != null) attribution["trackerToken"] = attributionData.TrackerToken;
    if (attributionData.TrackerName != null) attribution["trackerName"] = attributionData.TrackerName;
    if (attributionData.Network != null) attribution["network"] = attributionData.Network;
    if (attributionData.Adgroup != null) attribution["adgroup"] = attributionData.Adgroup;
    if (attributionData.Creative != null) attribution["creative"] = attributionData.Creative;
    if (attributionData.ClickLabel != null) attribution["clickLabel"] = attributionData.ClickLabel;
    if (attributionData.CostType != null) attribution["costType"] = attributionData.CostType;
    if (attributionData.CostAmount != null) attribution["costAmount"] = attributionData.CostAmount.ToString();
    if (attributionData.CostCurrency != null) attribution["costCurrency"] = attributionData.CostCurrency;
    if (attributionData.FbInstallReferrer != null) attribution["fbInstallReferrer"] = attributionData.FbInstallReferrer;

    // you will probably need to install Newtonsoft.Json package, if not yet
    var attributionJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(attribution);

    Adapty.UpdateAttribution(attributionJsonString, "adjust", (error) => {
        if (error != null) {
            // handle the error
        }
    });
}
```

</TabItem>

</Tabs>

## Cấu trúc sự kiện \{#event-structure\}

Adapty gửi các sự kiện đã chọn đến Adjust theo cấu hình trong mục **Events names** trên [**trang tích hợp Adjust**](https://app.adapty.io/integrations/adjust). Mỗi sự kiện có cấu trúc như sau:

```json
{
   "event_token": "EVENT_TOKEN_FROM_CONFIG",
   "app_token": "APP_TOKEN_FROM_CONFIG",
   "s2s": 1,
   "environment": "production",
   "created_at_unix": 1709294400,
   "currency": "USD",
   "revenue": 9.99,
   "customer_user_id": "user_12345",
   "external_device_id": "user_12345",
   "ip_address": "192.168.100.1",
   "user_agent": "Mozilla/5.0 (Linux; Android 14; SM-S901B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36",
   "android_id": "875646c2-4a56-4211-8931-168532479006",
   "gps_adid": "875646c2-4a56-4211-8931-168532479006",
   "callback_params": "{\"integration_event_id\":\"550e8400-e29b-41d4-a716-446655440000\",\"customer_user_id\":\"user_12345\",\"vendor_product_id\":\"com.example.app.yearly.premium\",\"transaction_id\":\"GPA.3312-4512-1100-55923\",\"original_transaction_id\":\"GPA.3312-4512-1100-55923\",\"store\":\"play_store\",\"store_country\":\"US\",\"price_usd\":9.99,\"proceeds_usd\":8.49,\"price_local\":9.99,\"proceeds_local\":8.49,\"net_revenue_usd\":8.49,\"net_revenue_local\":8.49,\"tax_amount_usd\":0.0,\"tax_amount_local\":0.0,\"consecutive_payments\":3,\"rate_after_first_year\":false}",
   "partner_params": "{\"integration_event_id\":\"550e8400-e29b-41d4-a716-446655440000\",\"customer_user_id\":\"user_12345\",\"vendor_product_id\":\"com.example.app.yearly.premium\",\"transaction_id\":\"GPA.3312-4512-1100-55923\",\"original_transaction_id\":\"GPA.3312-4512-1100-55923\",\"store\":\"play_store\",\"store_country\":\"US\",\"price_usd\":9.99,\"proceeds_usd\":8.49,\"price_local\":9.99,\"proceeds_local\":8.49,\"net_revenue_usd\":8.49,\"net_revenue_local\":8.49,\"tax_amount_usd\":0.0,\"tax_amount_local\":0.0,\"consecutive_payments\":3,\"rate_after_first_year\":false}"
}
```

Trong đó

| Tham số              | Kiểu    | Mô tả                                                                                                                                                                          |
|:---------------------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `app_token`          | String  | App Token của Adjust từ cài đặt tích hợp.                                                                                                                                      |
| `event_token`        | String  | Event Token của Adjust được ánh xạ đến sự kiện Adapty cụ thể.                                                                                                                 |
| `s2s`                | Integer | Cờ sự kiện Server-to-Server.                                                                                                                                                   |
| `environment`        | String  | `sandbox` hoặc `production`.                                                                                                                                                   |
| `created_at_unix`    | Integer | Timestamp của sự kiện tính bằng giây.                                                                                                                                          |
| `currency`           | String  | Mã tiền tệ (ví dụ: "USD") cho giao dịch. Chỉ được đưa vào khi doanh thu vượt quá 0.001, vì Adjust yêu cầu cả doanh thu và tiền tệ phải được gửi cùng nhau.                   |
| `revenue`            | Float   | Doanh thu giao dịch. Chỉ được đưa vào khi giá trị vượt quá 0.001. Lưu ý rằng sự kiện hoàn tiền được gửi không kèm thuộc tính doanh thu vì Adjust không hỗ trợ giá trị âm.   |
| `customer_user_id`   | String  | Customer User ID của người dùng.                                                                                                                                               |
| `external_device_id` | String  | Giống với `customer_user_id`.                                                                                                                                                  |
| `ip_address`         | String  | Địa chỉ IP của người dùng (chỉ IPv4).                                                                                                                                          |
| `user_agent`         | String  | Chuỗi User Agent của thiết bị.                                                                                                                                                 |
| `adid`               | String  | Adjust Device ID (nếu có).                                                                                                                                                     |
| `android_id`         | String  | **Chỉ Android**. Google Advertising ID.                                                                                                                                        |
| `gps_adid`           | String  | **Chỉ Android**. Google Advertising ID.                                                                                                                                        |
| `idfa`               | String  | **Chỉ iOS**. ID for Advertisers.                                                                                                                                               |
| `idfv`               | String  | **Chỉ iOS**. ID for Vendors.                                                                                                                                                   |
| `callback_params`    | String  | Chuỗi JSON chứa tất cả [các trường sự kiện](webhook-event-types-and-fields#for-most-event-types) có sẵn. Chỉ bao gồm các trường không null.                                   |
| `partner_params`     | String  | Giống với `callback_params`.                                                                                                                                                   |

## Khắc phục sự cố \{#troubleshooting\}

### Chênh lệch doanh thu \{#revenue-discrepancy\}

Nếu có sự chênh lệch doanh thu giữa Adapty và Adjust, nguyên nhân có thể là không phải tất cả người dùng của bạn đều sử dụng phiên bản ứng dụng có Adapty SDK. Để đảm bảo tính nhất quán của dữ liệu, bạn có thể yêu cầu người dùng cập nhật ứng dụng lên phiên bản có Adapty SDK.