Adjustは、モバイルアプリ、コンソールアプリ、コネクテッドTV(CTV)アプリ向けのサーバー間(S2S)インターフェイスを提供しています。サーバー間でAdjustを実装する場合は、Adjust SDKの機能を複製できるようにアプリを変更する必要があります。このガイドでは、以下の手順について説明します。
- 必要なアップデートをアプリに実装する方法
- Adjustへサーバー間リクエストを送信する方法
事前準備
事前準備として、以下を実行してください。
サーバー間セッション計測 を有効化する
モバイルアプリ向けにサーバー間インターフェイスを使用している場合、Adjustはアプリのサーバー間セッション計測を有効にする必要があります。ご希望の場合は、Adjustの担当者またはsupport@adjust.comにお問い合わせください。
プラットフォームを選択すると、コネクテッドTV計測とPCおよびコンソール計測のサーバー間セッション計測が自動的に有効になります。
S2Sセキュリティを設定する
サーバー間(S2S)セキュリティを実装してサーバー間のアクティビティを保護し、スプーフィングされたリクエストを防止します。Adjustダッシュボードでトークンを生成し、受信する各リクエストにそのトークンを含めます。
ローカルでイベントキューを保持する
ユーザーは、アプリのインストールやセッションなどの重要なイベントをオフラインのデバイスで実行することがあります。アトリビューションの正確性を維持するには、デバイスがオンラインになり、Adjustのサーバーに正常に送信できるようになるまで、これらのイベントを取得してローカルに格納しておく必要があります。
永続的なローカルイベントキューを可能にするには、以下の手順を実行します。
- アクティビティが発生した際に格納するためのキューを作成します。
- 各アクティビティには、デバイスでイベントが発生した時間を秒単位で示す
created_at_unix
タイムスタンプが付与されます。例えば、いつイベントが発生したのかを「1484085154
」のように表します。
- このキューをSQLiteデータベースやファイルなどのローカルストレージに保存して、アプリを再起動しても保持できるようにします。
- キューが空ではなく、デバイスがオンラインのときに、Adjustのサーバーにアクティビティの送信を試みます。
- アクティビティの送信が成功した場合のみ、キューからアクティビティを削除します。
このアプローチは、以下のような場合にデータ損失を最小に抑制します。
- 短時間のネットワーク中断(例:5GからWiFiへの切り替え時など)
- 長時間オンラインに復帰できない
- 送信前にアプリがクラッシュまたは強制終了
ローカルキューがない場合、インストールデータの10%~20%が失われる危険があり、アトリビューションの正確性に大きな影響が及ぶことがあります。このキューシステムを実装することで、Adjustはユーザーアクティビティを完全かつ正確に受信し、オフラインで発生したイベントであっても正確にアトリビューションできるようになります。
iOSフレームワークを追加する
特定のiOS機能をサポートするには、フレームワークをプロジェクトにリンクする必要があります。フレームワークをプロジェクトに追加するには、次の手順を実行します。
- Xcodeでプロジェクトを開きます。
- プロジェクトナビゲータで、ターゲットを選択します。
- General タブに移動します。
- Frameworks, Libraries, Embedded Content のセクションまでスクロールします。
- 「 + 」ボタンを選択します。
- 以下のリストを参考に、アプリに必要なフレームワークを検索して追加します。
Framework | 説明 |
---|
AdSupport.framework | IDFAの収集と、AppTrackingTransparency(ATT)以前のiOSバージョンで「Limit Ad Tracking(追跡型広告を制限)」ステータスを収集する場合に必要です。 |
AppTrackingTransparency.framework | AppTrackingTransparencyのポップアップを表示し、iOS 14.5以降を実行するデバイスでIDFAを収集する場合に必要です。 |
AdServices.framework | AdjustがApple Search Adsキャンペーンをアトリビュートするのに必要です。 |
StoreKit.framework | SKAdNetworkキャンペーンの実行に必要です。 |
必須パラメーター
各サーバー間リクエストには、以下のパラメーターが必要です。
パラメーター | 説明 |
---|
s2s | リクエストが「サーバー間リクエスト」であることを示します。「1 」にハードコーディングする必要があります。 |
app_token | Adjustのアプリトークン。 |
os_name | モバイルOS名。以下のオプションを参照してください。 |
android
android-tv
apple-tv
bada
blackberry
fire-tv
ios
linux
macos
nintendo
playstation
roku-os
server
smart-cast
steamos
symbian
tizen
unknown
webos
windows
windows-phone
xbox
これらのパラメーターをサーバー上に作成します。これらはデバイスの種類に関係なく、Adjustへ送信される全てのサーバー間リクエストに使用されます。デバイス固有のパラメーターは、必要に応じて追加されます。このガイドではクライアント側の全てのパラメーターの処理方法について説明しますが、実際は、その多くがサーバー側で発生します。
// Create dictionary for params to include on all S2S requests to Adjust
var params: [String: String] = [:]
// The name of the operating system running on the device
params["os_name"] = "ios"
// Replace with your Adjust app token
params["app_token"] = "4w565xzmb54d"
// Create dictionary for params to include on all S2S requests to Adjust
NSMutableDictionary *params = [NSMutableDictionary dictionary];
// The name of the operating system running on the device
params[@"os_name"] = @"ios";
// Replace with your Adjust app token
params[@"app_token"] = @"4w565xzmb54d";
// Create map for params to include on all S2S requests to Adjust
val params = mutableMapOf<String, String>()
// The name of the operating system running on the device
params["os_name"] = "android"
// Replace with your Adjust app token
params["app_token"] = "4w565xzmb54d"
// Create map for params to include on all S2S requests to Adjust
Map<String, String> params = new HashMap<>();
// The name of the operating system running on the device
params.put("os_name", "android");
// Replace with your Adjust app token
params.put("app_token", "4w565xzmb54d");
デバイスIDとトラッキングのステータス
全てのサーバー間リクエストには、 少なくとも1つ のデバイスIDを含める必要があります。モバイルのオペレーティングシステムがプライバシー対策を実装していることから、広告IDを常に利用できるとは限りません。そのため、可能な場合は広告IDを含めますが、常にバックアップのIDを含める必要があります。
PCおよびコンソール/コネクテッドTV(CTV)のデバイスID
PC、コンソールおよびコネクテッドTVを計測する場合、それぞれの呼び出しに一意のexternal_device_id
パラメーターを含めることで、デバイスIDとして使用できます。デバイスを識別する一意の値には、任意の文字列を指定できます。
iOSデバイスID
IDFAと計測ステータス
広告主ID(IDFA)は、ユーザーが共有することに同意したiOSデバイスでのみ利用可能です。IDFAを収集するアプリもあれば、そうでないアプリもありますが、アプリがIDFAを収集するかどうかに関係なく、Adjustは各リクエストのトラッキングステータスを要求します。以下から、実装環境に対応するコードを選んで使用してください。
IDFAを収集するアプリ
-
XcodeでATTの説明を追加します。
- プロジェクトの
Info.plist
ファイルを開きます。
- エディターで、 Information Property List を右クリックし、 Add Row を選択すると、ルートにキーを追加できます。
NSUserTrackingUsageDescription
にキーを設定します。
- トラッキングの許可を求める理由を文字列で設定します。例えば、「このIDは、パーソナライズされた広告を配信するために使用されます」のように入力します。このテキストについては、Appleのガイドラインを確認してください。
-
ATTポップアップの実装とIDFAの取得
ATTには以下の要件があります。
- ATTのサポートはiOS 14で開始されましたが、IDFAの取得にユーザーの同意が必要となるのはiOS 14.5以降のみです。このためAdjustは、iOS 14.5以降のバージョンを使用するユーザーに対してATTポップアップを表示することを推奨しています。
- ATTポップアップを表示するには、アプリをアクティブな状態にする必要があります。他のシステムポップアップの直後だと表示に失敗する可能性があるため、アプリの状態が再びアクティブになるまで待機しなければなりません。
- ポップアップを最も早く表示できるのは、
applicationDidBecomeActive
(App Delegate)またはsceneDidBecomeActive
(Scene Delegate)です。didFinishLaunchingWithOptions
(App Delegate)でATTポップアップを表示することはできません。
以下のコード例は、これらの要件を全て満たしています。
正確なアトリビューションを行うため、最初のセッションリクエストと、その後の全てのリクエストにIDFAを含めてください。
import AppTrackingTransparency
let attStatus: ATTrackingManager.AuthorizationStatus?
let trackingEnabled: Bool?
func getIDFAInfo(completion: @escaping (IDFAInfo) -> Void) {
// For iOS 14.5+, show ATT prompt to attempt to retrieve IDFA and retrieve ATT
if #available(iOS 14.5, *) {
// Wait briefly to ensure app is active
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
ATTrackingManager.requestTrackingAuthorization { status in
let idfa = (status == .authorized) ?
ASIdentifierManager.shared().advertisingIdentifier : nil
completion(IDFAInfo(idfa: idfa, attStatus: status,
// For earlier versions, don't show ATT prompt. Just get IDFA and tracking
let manager = ASIdentifierManager.shared()
let idfa = manager.isAdvertisingTrackingEnabled ?
manager.advertisingIdentifier : nil
let trackingEnabled = manager.isAdvertisingTrackingEnabled
completion(IDFAInfo(idfa: idfa, attStatus: nil,
trackingEnabled: trackingEnabled))
// Include IDFA if available
if let idfa = info.idfa?.uuidString {
// Include ATT status if available,
// otherwise include tracking enabled status, never both
if let attStatus = info.attStatus {
params["att_status"] = String(attStatus.rawValue)
} else if let trackingEnabled = info.trackingEnabled {
params["tracking_enabled"] = trackingEnabled ? "1" : "0"
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>
@interface IDFAInfo : NSObject
@property (nonatomic, strong) NSUUID *idfa;
@property (nonatomic, assign) ATTrackingManagerAuthorizationStatus attStatus;
@property (nonatomic, strong) NSNumber *trackingEnabled;
void getIDFAInfo(void (^completion)(IDFAInfo *)) {
// For iOS 14.5+, show ATT prompt to attempt to retrieve IDFA and retrieve ATT
if (@available(iOS 14.5, *)) {
// Wait briefly to ensure app is active
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC),
dispatch_get_main_queue(), ^{
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:
^(ATTrackingManagerAuthorizationStatus status) {
IDFAInfo *info = [[IDFAInfo alloc] init];
if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
info.idfa = [[ASIdentifierManager sharedManager]
// For earlier versions, don't show ATT prompt. Just get IDFA and tracking
ASIdentifierManager *manager = [ASIdentifierManager sharedManager];
IDFAInfo *info = [[IDFAInfo alloc] init];
if (manager.isAdvertisingTrackingEnabled) {
info.idfa = manager.advertisingIdentifier;
info.trackingEnabled = @(manager.isAdvertisingTrackingEnabled);
getIDFAInfo(^(IDFAInfo *info) {
// Include IDFA if available
params[@"idfa"] = [info.idfa UUIDString];
// Include ATT status if available, otherwise tracking enabled status, never both
if (info.attStatus != nil) {
params[@"att_status"] = [NSString stringWithFormat:@"%ld",
} else if (info.trackingEnabled != nil) {
params[@"tracking_enabled"] = [info.trackingEnabled boolValue] ?
IDFAを収集しないアプリ
以下のコードを使用して、トラッキングステータスを取得します。
let attStatus: ATTrackingManager.AuthorizationStatus?
let trackingEnabled: Bool?
func getTrackingInfo(completion: @escaping (TrackingInfo) -> Void) {
// For iOS 14.5+, get ATT status without showing prompt
if #available(iOS 14.5, *) {
let status = ATTrackingManager.trackingAuthorizationStatus
completion(TrackingInfo(attStatus: status, trackingEnabled: nil))
// For earlier versions, get tracking enabled status
let trackingEnabled = ASIdentifierManager.shared().isAdvertisingTrackingEnabled
completion(TrackingInfo(attStatus: nil, trackingEnabled: trackingEnabled))
getTrackingInfo { info in
// Include ATT status if available, otherwise tracking enabled status, never both
if let attStatus = info.attStatus {
params["att_status"] = String(attStatus.rawValue)
} else if let trackingEnabled = info.trackingEnabled {
params["tracking_enabled"] = trackingEnabled ? "1" : "0"
#import <AdSupport/AdSupport.h>
@interface TrackingInfo : NSObject
@property (nonatomic, assign) ATTrackingManagerAuthorizationStatus attStatus;
@property (nonatomic, strong) NSNumber *trackingEnabled;
@implementation TrackingInfo
void getTrackingInfo(void (^completion)(TrackingInfo *)) {
// For iOS 14.5+, get ATT status without showing prompt
if (@available(iOS 14.5, *)) {
TrackingInfo *info = [[TrackingInfo alloc] init];
info.attStatus = ATTrackingManager.trackingAuthorizationStatus;
// For earlier versions, get tracking enabled status
TrackingInfo *info = [[TrackingInfo alloc] init];
BOOL enabled = [ASIdentifierManager sharedManager].isAdvertisingTrackingEnabled;
info.trackingEnabled = @(enabled);
getTrackingInfo(^(TrackingInfo *info) {
// Include ATT status if available, otherwise tracking enabled status, never both
if (info.attStatus != nil) {
params[@"att_status"] = [NSString stringWithFormat:@"%ld",
} else if (info.trackingEnabled != nil) {
params[@"tracking_enabled"] = [info.trackingEnabled boolValue] ?
idfv
ベンダーID(DFV)は、最新のiOSデバイスの全てで利用可能なバックアップIDです。
let idfv: UUID? = UIDevice.current.identifierForVendor
if let idfvString = idfv?.uuidString {
params["idfv"] = idfvString
NSUUID *idfv = [[UIDevice currentDevice] identifierForVendor];
params[@"idfv"] = [idfv UUIDString];
メインの重複排除トークン
アンインストールと再インストールのアプリアクティビティを一貫して計測するには、バージョン4のUUID(メインの重複排除トークン)をランダムに生成し、iOSキーチェーンに保存します。メインの重複排除トークンは、全てのデバイスに対して生成する必要があるバックアップIDです。
let bundleId = "com.example.app"
// Collect the primary dedupe token from the keychain
func getPrimaryDedupeToken(bundleId: String) -> UUID? {
// Define the query to search for the token in the keychain
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: "primary_dedupe_token",
kSecAttrService as String: bundleId,
kSecReturnData as String: true
// Attempt to fetch the token from the keychain
let status = SecItemCopyMatching(query as CFDictionary, &item)
// If the fetch was successful, convert the result to a UUID
guard status == errSecSuccess,
let existingItem = item as? Data,
let uuidString = String(data: existingItem, encoding: .utf8),
let token = UUID(uuidString: uuidString) else {
// Return nil if the token doesn't exist or couldn't be collected
// Save the primary dedupe token to the keychain
func setPrimaryDedupeToken(_ token: UUID, bundleId: String) -> Bool {
let tokenData = token.uuidString.data(using: .utf8)!
// Define the attributes for storing the token in the keychain
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: "primary_dedupe_token",
kSecAttrService as String: bundleId,
kSecValueData as String: tokenData,
kSecAttrAccessible as String: kSecAttrAccessibleAfterFirstUnlock
// Attempt to add the token to the keychain
let status = SecItemAdd(query as CFDictionary, nil)
// Return true if the token was successfully added, false otherwise
return status == errSecSuccess
// Collect the existing primary dedupe token or create a new one if it doesn't exist
func getOrCreatePrimaryDedupeToken() -> UUID {
// Try to collect an existing token
if let existingToken = getPrimaryDedupeToken(bundleId: bundleId) {
// If no token exists, generate a new one
// Attempt to save the new token
if setPrimaryDedupeToken(newToken, bundleId: bundleId) {
// If saving fails, throw a fatal error
fatalError("Failed to save primary dedupe token")
let primaryDedupeToken = getOrCreatePrimaryDedupeToken()
// Convert to lowercase string
params["primary_dedupe_token"] = primaryDedupeToken.uuidString.lowercased()
#import <Foundation/Foundation.h>
#import <Security/Security.h>
NSString *const bundleId = @"com.example.app";
// Collect the primary dedupe token from the keychain
NSUUID *getPrimaryDedupeToken(NSString *bundleId) {
// Define the query to search for the token in the keychain
(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
(__bridge id)kSecAttrAccount: @"primary_dedupe_token",
(__bridge id)kSecAttrService: bundleId,
(__bridge id)kSecReturnData: @YES
// Attempt to fetch the token from the keychain
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query,
// If the fetch was successful, convert the result to a UUID
if (status == errSecSuccess && item != NULL) {
NSData *existingItem = (__bridge_transfer NSData *)item;
NSString *uuidString = [[NSString alloc]
initWithData:existingItem encoding:NSUTF8StringEncoding];
return [[NSUUID alloc] initWithUUIDString:uuidString];
// Return nil if the token doesn't exist or couldn't be collected
// Save the primary dedupe token to the keychain
BOOL setPrimaryDedupeToken(NSUUID *token, NSString *bundleId) {
NSData *tokenData = [[token UUIDString]
dataUsingEncoding:NSUTF8StringEncoding];
// Define the attributes for storing the token in the keychain
(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
(__bridge id)kSecAttrAccount: @"primary_dedupe_token",
(__bridge id)kSecAttrService: bundleId,
(__bridge id)kSecValueData: tokenData,
(__bridge id)kSecAttrAccessible:
(__bridge id)kSecAttrAccessibleAfterFirstUnlock
// Attempt to add the token to the keychain
OSStatus status = SecItemAdd((__bridge CFDictionaryRef)query, NULL);
// Return YES if the token was successfully added, NO otherwise
return status == errSecSuccess;
// Collect the existing primary dedupe token or create a new one if it doesn't exist
NSUUID *getOrCreatePrimaryDedupeToken(void) {
// Try to collect an existing token
NSUUID *existingToken = getPrimaryDedupeToken(bundleId);
// If no token exists, generate a new one
NSUUID *newToken = [NSUUID UUID];
// Attempt to save the new token
if (setPrimaryDedupeToken(newToken, bundleId)) {
// If saving fails, throw an exception
@throw [NSException exceptionWithName:@"TokenSaveError"
reason:@"Failed to save primary dedupe token"
NSUUID *primaryDedupeToken = getOrCreatePrimaryDedupeToken();
// Convert to lowercase string
params[@"primary_dedupe_token"] = [[primaryDedupeToken UUIDString]
Google PlayデバイスID(Android)
Google広告ID
Google Play開発者サービスの広告ID(GPS ADID)は、ユーザーが広告IDの削除を選択していない場合、Google Play開発サービスを搭載したAndroidデバイスで利用可能です。
- アプリの
build.gradle
ファイルに、dependencyとしてplay-services-ads-identifier
を追加します。
implementation("com.google.android.gms:play-services-ads-identifier:18.1.0")
implementation 'com.google.android.gms:play-services-ads-identifier:18.1.0'
-
以下のパーミッションをAndroidManifest.xml
ファイルに追加します。
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
-
アプリでR8またはProGuardを使用している場合は、proguard-rules.pro
ファイルに以下のルールを追加して、コード最適化中にGoogle広告IDを取得するためのクラスとメソッドを保持します。ファイルが存在しない場合は、アプリモジュールのディレクトリ内でファイルを作成してください。
-keep class com.google.android.gms.common.ConnectionResult {
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.
AdvertisingIdClient$Info getAdvertisingIdInfo(
android.content.Context);
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
-
Google広告IDとトラッキングステータスを収集するためのコードを実装します。
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
suspend fun getGoogleAdvertisingIdInfo(
context: Context): AdvertisingIdClient.Info? {
return withContext(Dispatchers.IO) {
AdvertisingIdClient.getAdvertisingIdInfo(context)
// (for example: Google Play Services not available)
// As getGoogleAdvertisingIdInfo is a suspending function,
// it should be called from within a coroutine scope.
val adInfo = getGoogleAdvertisingIdInfo(context)
// Include Google Advertising ID if tracking is not limited
if (!info.isLimitAdTrackingEnabled) {
params["gps_adid"] = info.id
params["tracking_enabled"] = if (info.isLimitAdTrackingEnabled)
App Set ID
App Set IDは、Google Play開発者サービスがインストールされており、APIレベル30(Android 11)以降を実行する全てのAndroidデバイスで利用可能なバックアップIDです。
- アプリの
build.gradle
ファイルに、必要なdependencyを追加します。
implementation("com.google.android.gms:play-services-appset:16.1.0")
implementation 'com.google.android.gms:play-services-appset:16.1.0'
- App Set IDを収集するためのコードを実装します。
import com.google.android.gms.appset.AppSet
import com.google.android.gms.appset.AppSetIdClient
import com.google.android.gms.appset.AppSetIdInfo
import com.google.android.gms.tasks.Tasks
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
suspend fun getAppSetId(context: Context): String? {
return withContext(Dispatchers.IO) {
val client: AppSetIdClient = AppSet.getClient(context)
val taskResult = Tasks.await(client.appSetIdInfo)
// Handle exceptions (for example: Google Play Services not available)
// As getAppSetId is a suspending function,
// it should be called from within a coroutine scope.
val appSetId = getAppSetId(context)
val params = mutableMapOf<String, String>()
params["google_app_set_id"] = id
追加パラメーター
これらのパラメーターは必須ではありませんが、いずれかを使用する場合は、全てのリクエストに含める必要があります。
Unixタイムスタンプ
各サーバー間リクエストにUnixのタイムスタンプを含めると、デバイスでアクティビティが発生した時刻が提供されるため、アトリビューションの正確性が向上します。
// Unix timestamp of when activity occurred on device
// Code example shows how to retrieve current time in seconds
// Example value: "1484085154"
params["created_at_unix"] = String(Int(Date().timeIntervalSince1970))
// Unix timestamp of when activity occurred on device
// Code example shows how to retrieve current time in seconds
// Example value: "1484085154"
params["created_at_unix"] = (System.currentTimeMillis() / 1000).toString()
確率的モデリングのデータポイント
確率的モデリングをアトリビューションメソッドとして使用するには、全てのサーバー間リクエストに以下のパラメーターを含める必要があります。
パラメーター | 説明 |
---|
device_name | デバイス名。 |
device_type | デバイスのタイプまたはモデル。 |
os_version | デバイス上で動作するオペレーティングシステムのバージョン。 |
ip_address | デバイスのIPアドレス。 |
特にiOSの場合により包括的なアトリビューションが可能になるため、Adjustはこれらのパラメーターを追加することを強くお勧めしています。
// Example value: "iPhone10,5"
var systemInfo = utsname()
let machineMirror = Mirror(reflecting: systemInfo.machine)
let deviceName = machineMirror.children.reduce("") {
guard let value = element.value as? Int8, value != 0
else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
params["device_name"] = deviceName
// Example value: "iPhone"
params["device_type"] = UIDevice.current.model
// Example value: "17.5.1"
params["os_version"] = UIDevice.current.systemVersion
// Retrieve the device's IP address from requests to your server
params["ip_address"] = "192.0.0.1" // Example value
import android.content.Context
import android.content.res.Configuration
import android.content.pm.PackageManager
val context: Context = // ... get your context here ...
val isGooglePlayGamesForPC = context.packageManager
.hasSystemFeature("com.google.android.play.feature
params["device_name"] = if (isGooglePlayGamesForPC) null
params["os_version"] = if (isGooglePlayGamesForPC) null
else Build.VERSION.RELEASE
params["device_type"] = when {
isGooglePlayGamesForPC -> "pc"
(context.resources.configuration.uiMode and
Configuration.UI_MODE_TYPE_MASK) == Configuration
.UI_MODE_TYPE_TELEVISION -> "tv"
else -> when (context.resources.configuration.screenLayout
and Configuration.SCREENLAYOUT_SIZE_MASK) {
Configuration.SCREENLAYOUT_SIZE_SMALL,
Configuration.SCREENLAYOUT_SIZE_NORMAL -> "phone"
Configuration.SCREENLAYOUT_SIZE_LARGE,
Configuration.SCREENLAYOUT_SIZE_XLARGE -> "tablet"
// Retrieve the device's IP address from requests to
params["ip_address"] = "192.0.0.1" // Example value
環境
environment
パラメーターを渡すことで、リクエストが送信される環境を指定できます。テストを可能にするために、Adjustでは異なる環境からのリクエストを分離して管理します。利用可能な値は以下のとおりです。
sandbox
: テスト用のリクエストを本番用データと分けるため、テスト時に使用します。
production
: アプリをリリースする際に使用する本番用環境です。
このパラメーターを指定しない場合、デフォルト値はproduction
となります。
// For testing (sandbox environment)
params["environment"] = "sandbox"
params["environment"] = "production"
// For testing (sandbox environment)
params["environment"] = "sandbox"
params["environment"] = "production"
グローバルコールバックパラメーター
ローデータのエクスポートを使用する場合、全てのサーバー間リクエストに「グローバルコールバック」を含めることで、ローデータにカスタムパラメーターを追加できます。これは通常、エクスポートされたローデータに内部ユーザーIDを含めるために使用します。
グローバルコールバックパラメーターは、文字列のキーと値のペアを含むJSONオブジェクトとして表されます。
params["callback_params"] = '{"user_id": "2696775149", "user_category": "high value"}'
params["callback_params"] = '{"user_id": "2696775149", "user_category": "high value"}'
グローバルパートナーパラメーター
特定のパートナーと連携する際、全てのサーバー間リクエストに「グローバルパートナーパラメーター」を含める場合があります。Adjustのサーバーは、パートナーへの全てのコールバックで、これらのパラメーターを渡します。これは通常、受信するコールバックに独自のユーザーIDを要求するアナリティクスパートナー向けに使用されます。
グローバルパートナーは、文字列のキーと値のペアを含むJSONオブジェクトとして表されます。
params["partner_params"] = '{"analytics_user_id": "3913132433", "analytics_visitor_id": "nzFC9LKSqM"}'
params["partner_params"] = '{"analytics_user_id": "3913132433", "analytics_visitor_id": "nzFC9LKSqM"}'
リクエスト
セッション
セッションは、Adjust実装の基盤として必要となる唯一のアクティビティです。セッションとは一般的に、アプリが開かれることを指します。Adjustのサーバーは、正常なセッションリクエストを次のようにログに記録します。
- デバイスの最初のセッションを「インストール」アクティビティとして記録します。
- 以降のセッションを「セッション」アクティビティとして記録します。
- リアトリビューションの基準が満たされている場合は、「リアトリビューション」または「リアトリビューション再インストール」のアクティビティを記録します。
送信するサーバー間セッションリクエストにcreated_at_unix
パラメーターが含まれる場合、Adjustのサーバーはこのパラメーター値が、ログに記録された最後のセッションのcreated_at_unix
時間から20分以上経過していることを確認します。
curl -X POST "https://app.adjust.com/session" \ -H "Authorization: Bearer ADD_YOUR_AUTH_TOKEN_HERE" \
-H "Content-Type: application/x-www-form-urlencoded" \
&idfa=29DDE430-CE81-4F00-A50C-689595AAD142\
&idfv=59E27F41-A86B-4560-B585-63161F871C4B\
&primary_dedupe_token=3b35fcfb-6115-4cff-830f-e32a248c487d\
&created_at_unix=1484085154\
&device_name=iPhone16%2C2\
&callback_params=%7B%22user_id%22%3A%20%222696775149%22%2C%20%22user_category%22%3A%20%22high%20value%22%7D\
&partner_params=%7B%22analytics_user_id%22%3A%20%223913132433%22%2C%20%22analytics_session_id%22%3A%20%22nzFC9LKSqM%22%7D"\
-w "\n\nHTTP Status Code: %{http_code}\n"\
これは、Adjustでデバイスの最初のセッションを正常にログに記録するためのレスポンスフォーマットです。Adjustのテストコンソールを使用すれば、実際のデバイスを利用せずに、必要に応じて何度でもテストできます。
"app_token": "4w565xzmb54d",
"adid": "df6c5653080670612cd2f9766ddc0814",
"timestamp": "2024-07-09T01:31:14.373Z+0000",
"message": "Install tracked",
これは、Adjustでデバイスの以降のセッションを正常にログに記録するためのレスポンスフォーマットです。
"app_token": "4w565xzmb54d",
"adid": "df6c5653080670612cd2f9766ddc0814",
"timestamp": "2024-07-09T02:31:14.373Z+0000",
"message": "Session tracked",
インストール後のイベント
デバイスのセッションリクエストを少なくとも1つ正常に送信すると、インストール後のイベントを送信できるようになります。これらは通常、マーケティング目標を表すイベントであり、ネットワークはこれをキャンペーンの最適化に使用できます。
// Add event token to existing params
params["event_token"] = "2y7e81"
// Add revenue and currency, if applicable
// These parameters are equivalent to $19.99
params["revenue"] = "19.99"
params["currency"] = "USD"
// Add event token to existing params
params["event_token"] = "2y7e81"
// Add revenue and currency, if applicable
// These parameters are equivalent to $19.99
params["revenue"] = "19.99"
params["currency"] = "USD"
コールバックパラメーター
ローデータエクスポートを使用する場合、特定のイベントリクエストにカスタムの「コールバックパラメーター」を含めることで、イベントレベルのカスタムデータを追加できます。たとえば、購入イベントのローデータに内部のトランザクションIDを含めることが可能です。
コールバックパラメーターは、文字列のキーと値のペアを含むJSONオブジェクトとして表されます。
// If callback_params exists, add the event callback parameters to it (for example: txn_id)
params["callback_params"] = '{"user_id": "2696775149", "user_category": "high value", "txn_id": "8837853376"}'
// If callback_params does not exist, create it
params["callback_params"] = '{"txn_id": "8837853376"}'
// If callback_params exists, add the event callback parameters to it (for example: txn_id)
params["callback_params"] = '{"user_id": "2696775149", "user_category": "high value", "txn_id": "8837853376"}'
// If callback_params does not exist, create it
params["callback_params"] = '{"txn_id": "8837853376"}'
パートナーパラメーター
特定のパートナーと連携する場合は、イベントリクエストにカスタムの「パートナーパラメーター」を含める必要があります。その後、Adjustのサーバーは、パートナーに送信する関連イベントのコールバックにこれらのパラメーターを追加するようになります。これは、view_item
、add_to_cart
、購入などのイベントの動的なリマーケティングキャンペーンを可能にする、最も一般的な方法です。
パートナーパラメーターは、文字列のキーと値のペアを含むJSONオブジェクトとして表されます。
// If partner_params exists, add the event partner parameters to it (for example: item_id)
params["partner_params"] = '{"analytics_user_id": "3913132433", "analytics_session_id": "nzFC9LKSqM", "item_id": "[\"76524\",\"62599\"]"}'
// If partner_params does not exist, create it
params["partner_params"] = '{"item_id": "[\"76524\",\"62599\"]"}'
// If partner_params exists, add the event partner parameters to it (for example: item_id)
params["partner_params"] = '{"analytics_user_id": "3913132433", "analytics_session_id": "nzFC9LKSqM", "item_id": "[\"76524\",\"62599\"]"}'
// If partner_params does not exist, create it
params["partner_params"] = '{"item_id": "[\"76524\",\"62599\"]"}'
イベントリクエストを送信します。
curl -X POST "https://app.adjust.com/event" \
-H "Authorization:Bearer ADD_YOUR_AUTH_TOKEN_HERE" \
-H "Content-Type:application/x-www-form-urlencoded" \
&idfa=29DDE430-CE81-4F00-A50C-689595AAD142\
&idfv=59E27F41-A86B-4560-B585-63161F871C4B\
&primary_dedupe_token=3b35fcfb-6115-4cff-830f-e32a248c487d\
&created_at_unix=1484085154\
&device_name=iPhone16%2C2\
&callback_params=%7B%22user_id%22%3A%20%222696775149%22%2C%20%22user_category%22%3A%20%22high%20value%22%2C%20%22txn_id%22%3A%20%228837853376%22%7D\
&partner_params=%7B%22analytics_user_id%22%3A%20%223913132433%22%2C%20%22analytics_session_id%22%3A%20%22nzFC9LKSqM%22%2C%20%22item_id%22%3A%20%22%5B%5C%2276524%5C%22%2C%5C%2262599%5C%22%5D%22%7D"\
-w "\n\nHTTP Status Code: %{http_code}\n"\