LLM 用にコピー Markdown で表示 ツールをインストール Adaptyがインストールをキャンペーンに紐付けると、onInstallationDetailsSuccess コールバックを通じてアトリビューションデータをアプリに返します。このデータを使用して、インストールを促したチャネルやキャンペーンに基づいてユーザー体験をパーソナライズできます。
アトリビューションデータは、payload フィールド内のネストされた attribution オブジェクトとして返されます。以下のフィールドが含まれます:
フィールド 説明 channel獲得チャネル(例:facebook、tiktok、google、organic) campaign_idキャンペーン識別子 campaign_nameキャンペーン名 adset_id広告セット / 広告グループの識別子 adset_name広告セット / 広告グループ名 ad_id広告 / クリエイティブの識別子 ad_name広告 / クリエイティブ名
すべてのフィールドはオプションです。オーガニックインストールやアトリビューションが判定できない場合、payload フィールドには attribution オブジェクトが含まれません。
アプリでアトリビューションデータを読み取るには:
Copy Adapty.delegate = self
nonisolated func onInstallationDetailsSuccess ( _ details: AdaptyInstallationDetails) {
guard
let payloadDict = details.payload ? . dictionary ,
let attribution = payloadDict[ "attribution" ] as? [ String : Any ]
else { return }
let channel = attribution[ "channel" ] as? String
let campaignName = attribution[ "campaign_name" ] as? String
let adName = attribution[ "ad_name" ] as? String
print ( "Channel: \( channel ?? "organic" ) " )
} Copy Adapty. setOnInstallationDetailsListener ( object : OnInstallationDetailsListener {
override fun onInstallationDetailsSuccess (details: AdaptyInstallationDetails ) {
val payloadStr = details.payload ?: return
runCatching {
val payload = JSONObject (payloadStr)
val attribution = payload. optJSONObject ( "attribution" ) ?: return
val channel = attribution. optString ( "channel" )
val campaignName = attribution. optString ( "campaign_name" )
val adName = attribution. optString ( "ad_name" )
println ( "Channel: $channel " )
}. onFailure (Throwable:: printStackTrace )
}
}) Copy adapty. addEventListener ( 'onInstallationDetailsSuccess' , details => {
try {
if ( ! details.payload) return ;
const payload = JSON . parse (details.payload);
const attribution = payload.attribution;
if ( ! attribution) return ;
const channel = attribution.channel;
const campaignName = attribution.campaign_name;
const adName = attribution.ad_name;
console. log ( 'Channel:' , channel ?? 'organic' );
} catch (error) {
console. error ( 'Error parsing payload:' , error);
}
}); Copy Adapty ().onUpdateInstallationDetailsSuccessStream. listen ((details) {
final payloadStr = details.payload;
if (payloadStr == null ) return ;
final payload = json. decode (payloadStr) as Map < String , dynamic >;
final attribution = payload[ 'attribution' ] as Map < String , dynamic > ? ;
if (attribution == null ) return ;
final channel = attribution[ 'channel' ] as String ? ;
final campaignName = attribution[ 'campaign_name' ] as String ? ;
final adName = attribution[ 'ad_name' ] as String ? ;
print ( 'Channel: ${ channel ?? 'organic' } ' );
});