---
title: "Tenjin連携"
description: ""
---

Tenjinは、アプリ開発者やマーケター向けのモバイルアトリビューション・分析プラットフォームです。広告ネットワークやアプリストアのデータを集約し、ROIの分析、コンバージョンのトラッキング、主要なパフォーマンス指標のモニタリングを可能にします。透明性が高く柔軟なアプローチで、ユーザー獲得キャンペーンの計測と最適化を支援します。

[サブスクリプションイベント](events)をTenjinに転送することで、コンバージョンの発生源や最も価値をもたらすキャンペーンを、すべてのチャネル・プラットフォーム・デバイスにわたって正確に把握できます。TenjinのダッシュボードはマーケティングキャンペーンのA/Bテスト向け高度な分析機能を提供します。

TenjinのアトリビューションをAdaptyに転送することで、Adaptyのアナリティクスにコホート分析やコンバージョン分析で活用できる追加フィルタ条件を追加できます。

この連携は2つの方法で機能します：

1. **Tenjinからアトリビューションデータを受け取る**
   連携後、AdaptyはTenjinからアトリビューションデータを収集します。この情報はAdapty Dashboardのユーザーのプロファイルページで確認できます。
2. **サブスクリプションイベントをTenjinに送信する**
   Adatyはリアルタイムで購入イベントをTenjinに送信します。これらのイベントを使って、Tenjinのダッシュボード内で広告キャンペーンの効果を直接評価できます。

| 連携の特性 | 説明                                                  |
| -------------------------- | ------------------------------------------------------------ |
| スケジュール                   | リアルタイム                                                    |
| データの方向             | <p>双方向転送：</p><ul><li> **Adaptyイベント**：AdaptyサーバーからTenjinサーバーへ</li><li> **Tenjinアトリビューション**：Tenjin SDKからAdaptyサーバーへ</li></ul> |
| Adaptyの連携ポイント   | <ul><li> モバイルアプリコード内のTenjinとAdapty SDK</li><li> Adaptyサーバー</li></ul> |

## 連携のセットアップ \{#set-up-integration\}

### AdaptyをTenjinに接続する \{#connect-adapty-to-tenjin\}

1. Adapty Dashboardの[**Integrations** -> **Tenjin**](https://app.adapty.io/integrations/tenjin)ページを開きます。

2. トグルを有効にして連携をアクティブにします。

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

3. [Tenjin Dashboard](https://tenjin.com/)にログインします。

4. ナビゲーションメニューで**Configuration** -> **Apps**に移動します。

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

5. お使いのプラットフォーム（iOSまたはAndroid）のアプリを選択し、**App and SDK**タブに移動します。

6. **App and SDK**タブで、**SDK Key**列の**Copy**をクリックします。SDKキーがまだない場合は、**Generate SDK Key**ボタンをクリックして作成します。

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

7. Adapty Dashboardに戻り、コピーしたSDKキーを対応するプラットフォームのフィールドに貼り付けます：
   - iOSアプリの場合：**iOS SDK Key**または**iOS Sandbox SDK Key**フィールドに貼り付けます
   - Androidアプリの場合：**Android SDK Key**または**Android Sandbox SDK Key**フィールドに貼り付けます

   :::info

   Tenjinにはサーバー間連携向けの専用サンドボックスモードはありません。本番環境とサンドボックスイベントの両方に、別のTenjinアプリまたは同じキーを使用してください。
   :::

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

8. 両方のプラットフォームにアプリがある場合は、もう一方のプラットフォームについて手順5〜7を繰り返します。

9. （任意）必要に応じて**How the revenue data should be sent**セクションを調整します。設定の詳細については、[連携設定](configuration#integration-settings)を参照してください。

10. **Save**をクリックしてセットアップを完了します。

これでAdaptyはTenjinに購入イベントを送信し、アトリビューションデータを受信します。**Events names**セクションでイベントの共有を調整できます。

### イベントとタグを設定する \{#configure-events-and-tags\}

Tenjinは購入イベントと**Trial started**イベントのみを受け付けます。**Events names**セクションで、トラッキング目標に合わせてTenjinと共有するイベントを選択します。

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

### アプリをTenjinに接続する \{#connect-your-app-to-tenjin\}

`Adapty.updateAttribution()` SDKメソッドを使用してTenjinからアトリビューションデータを取得し、Adaptyに渡します。

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

```swift showLineNumbers

func updateTenjinId() {
    guard let tenjinId = TenjinSDK.getAnalyticsInstallationId() else { return }

    do {
        // Adapty SDK 4.x
        try await Adapty.setIntegrationIdentifier(.tenjinAnalyticsInstallationId(tenjinId))
        // Adapty SDK 3.x
        try await Adapty.setIntegrationIdentifier(
            key: "tenjin_analytics_installation_id",
            value: tenjinId
        )
    } catch {
        // handle the error
    }
}

func updateTenjinAttribution() {
    let instance = TenjinSDK.getInstance("<YOUR_TENJIN_API_TOKEN>")
        
    instance?.getAttributionInfo { info, _ in
        guard let info else { return }

        Task {
            do {
                // Adapty SDK 4.x
                try await Adapty.updateAttribution(info, source: .tenjin)
                // Adapty SDK 3.x
                try await Adapty.updateAttribution(info, source: "tenjin")
            } catch {
                // handle the error
            }
        }
    }
}
```

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

```kotlin showLineNumbers
Adapty.setIntegrationIdentifier("tenjin_analytics_installation_id", tenjinSdk.analyticsInstallationId) { error ->
    if (error != null) {
        // handle the error
    }
}

tenjinSdk.getAttributionInfo { attribution ->
    if (attribution == null) return@getAttributionInfo

    Adapty.updateAttribution(attribution, "tenjin") { error ->
        if (error != null) {
            // handle the error
        }
    }
}
```

</TabItem>

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

```java showLineNumbers
Adapty.setIntegrationIdentifier("tenjin_analytics_installation_id", tenjinSdk.getAnalyticsInstallationId(), error -> {
    if (error != null) {
        // handle the error
    }
});

tenjinSdk.getAttributionInfo(attribution -> {
    if (attribution == null) return;

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

</TabItem>

<TabItem value="flutter" label="Flutter (Dart)" default>

```javascript showLineNumbers
try {
    final tenjinId = await TenjinSDK.instance.getAnalyticsInstallationId();
    
    if (tenjinId != null) {
        await Adapty().setIntegrationIdentifier(
            key: 'tenjin_analytics_installation_id', 
            value: tenjinId,
        );
    }

    final attribution = await TenjinSDK.instance.getAttributionInfo();
    if (attribution != null) {
        await Adapty().updateAttribution(attribution, source: 'tenjin');
    }
} catch (e) {
    // handle the error
}
```

</TabItem>
<TabItem value="unity" label="Unity (C#)" default>

```csharp showLineNumbers
using AdaptySDK;
using System.Linq;

BaseTenjin instance = Tenjin.getInstance("<SDK_KEY>");
var tenjinId = instance.GetAnalyticsInstallationId();

Adapty.SetIntegrationIdentifier(
    "tenjin_analytics_installation_id",
    tenjinId,
    (error) => {
        // handle the error
    });

instance.GetAttributionInfo((attribution) => {
    var dynamicAttribution = attribution.ToDictionary(
        kvp => kvp.Key,
        kvp => (dynamic)kvp.Value
    );
                
Adapty.UpdateAttribution(
    dynamicAttribution,
    "tenjin",
    (error) => {
        // handle the error
    });
});
```

</TabItem>

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

```typescript showLineNumbers

// ...
const posthog = usePostHog()

// ...
try {
  await adapty.setIntegrationIdentifier("tenjin_analytics_installation_id", await Tenjin.getAnalyticsInstallationId());
} catch (error) {
  // handle `AdaptyError`
}
```

</TabItem>
</Tabs>

## イベント構造 \{#event-structure\}

Adatyは[**Tenjin Integration page**](https://app.adapty.io/integrations/tenjin)の**Events names**セクションで設定した選択済みイベントをTenjinに送信します。各イベントの構造は次のとおりです：

```json showLineNumbers title="Json"
{
  "price": 99.0,
  "locale": "en-US",
  "country": "ME",
  "postcut": "false",
  "currency": "USD",
  "platform": "ios",
  "quantity": 1,
  "bundle_id": "com.adapty.adaptydemoapp",
  "ip_address": "127.0.0.1",
  "os_version": "18.1.1",
  "product_id": "month.premium.99",
  "app_version": "3.2.0",
  "sdk_version": "server",
  "device_model": "iPhone 13 Mini",
  "advertising_id": "00000000-0000-0000-0000-000000000000",
  "os_version_release": "18.1.1",
  "developer_device_id": "00000000-0000-0000-0000-000000000000",
  "analytics_installation_id": "00000000-0000-0000-0000-000000000000"
}
```

各パラメーターの説明：

| **パラメーター**                 | **型**         | **説明**                                              |
| ----------------------------- | ---------------- | ------------------------------------------------------------ |
| **price**                     | Float            | 購入アイテムの単価（通貨の標準単位。例：USDはドル単位で報告）。 |
| **locale**                    | String           | デバイスのロケール。Android：`Locale.getDefault().toString()`、iOS：`[[NSLocale currentLocale] localeIdentifier]`。 |
| **country**                   | String           | ISO標準の国コード（例：米国はUS）。 |
| **postcut**                   | String (Boolean) | プラットフォームの手数料差し引き後に購入が送信されたかどうかを示します。trueの場合は1、falseの場合は0。 |
| **currency**                  | String           | ISO通貨コード（例：米ドルはUSD）。 |
| **platform**                  | String           | デバイスのプラットフォーム（例：ios、android、windows、amazon）。 |
| **quantity**                  | Integer          | 購入した数量。 |
| **bundle_id**                 | String           | アプリのバンドル識別子（例：`com.example.app`）。 |
| **ip_address**                | String (IPv4)    | ユーザーのIPアドレス。国の検索に使用されます。 |
| **os_version**                | String           | デバイスのOSバージョン。Android：`String.valueOf(Build.VERSION.SDK_INT)`、iOS：`[[UIDevice currentDevice] systemVersion]`。 |
| **product_id**                | String           | 購入したプロダクトの一意識別子。 |
| **app_version**               | Float, Decimal   | アプリのバージョン。Android：`context.getPackageManager().getPackageInfo()`、iOS：`[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]`。 |
| **sdk_version**               | String           | 使用中のSDKバージョン。常に`server`に設定されます。 |
| **device_model**              | String           | デバイスのモデル。Android：`Build.MODEL`、iOS：`sysctl("hw.machine")`。 |
| **advertising_id**            | UUID             | デバイスの広告ID。Androidでは必須です。iOSでは空またはすべてゼロになることがあります。 |
| **os_version_release**        | String           | OSバージョンのリリース情報。Android：`String.valueOf(Build.VERSION.RELEASE)`、iOS：`[[UIDevice currentDevice] systemVersion]`。 |
| **developer_device_id**       | UUID             | ベンダー識別子（iOSのみ）。 |
| **analytics_installation_id** | UUID             | アナリティクスインストールID。詳細については、`https://docs.tenjin.com`のドキュメントを参照してください。 |