attributionToken()
Generates a token.
Declaration
class func attributionToken() throws -> StringDiscussion
The token that the framework returns is a Base64 encoded string and has a 24-hour TTL. You can provide the token to a Mobile Measurement Provider (MMP), or app developers can use it to make a POST API call to fetch attribution records within the 24-hour TTL window. Use a single token in the request body and use a content-type of text/plain in the header, as the following example shows:
POST https://api-adservices.apple.com/api/v1/
--header 'Content-Type: text/plain' \
--data-raw
G9i5hC8lQJeGOfmS+MFycll/025oJEjtpZ+rs4AUkDEJh52fT8RrjwIR/h+2JOpXz4MRdmtcemL8WTTHfNN52tjqjbWupke40AAAAVADAAAAvQAAAIAgQF1+XF4Tl2IZ7Bw/M6ufUHt+UcIhuBeJT8YenB2v36bnZKEjvq/IH8rqXkRELTHdyiqOYtpy837+UjF/NjE6t1/l7sIn71b0t3FEXJd8QOtl3Bi6iQyJgGeN8w8X0MK1PDqz9nLJtRD/wl+p112qR2YrMDyyKnwNrbfRhnGB9AAAAB7wAXlwNHelWf5RT2bzSJcGflqELMCGoDEHIl7jF6kAAACfAb9ylY8ffdbTlyJODQYQ/6V9qbaBAAAAhgUBW39MQI1A0SZgNmZFz4KPaF94BxBzd4rDkjr/eSeuaXWCmEW3ZhBzE/MOM17hAPBVlDhTPcZ/2ybr3WYIkfb+AAg/7jxGpDXgTtco3fzTytnZpEaI5SenXHALIexQAUTBsfBW2HCMQuTRo+7anoWkf69656ZAWcSc3DEQ1CAkUSKO9X7iAAABBEQQBQA=For details about error codes, see AAAttributionError.
Response codes
Response | Description |
|---|---|
200 | Success. If the API finds a matching attribution record, the payload returns |
400 | The token is invalid. |
404 | Not found. The API is unable to retrieve the requested attribution record. [Image]Tokens have a TTL of 24 hours. If the |
500 | The Apple Ads server is temporarily down or unreachable. The request may be valid, but you need to retry it later. |
Attribution payloads
The attribution record is a data dictionary with key-value pairs that correspond to your Apple Ads campaigns and app downloads from devices running iOS 14 and later. Run reports to review detailed campaign metadata in the Apple Ads Platform API or Apple Ads Advanced.
{
"attribution": true,
"orgId": 1234567890,
"campaignId": 1234567890,
"conversionType": "Download",
"clickDate": "2020-04-08T17:17Z",
"claimType": "Click",
"adGroupId": 1234567890,
"countryOrRegion": "US",
"keywordId": 123222,
"adId": 542317136,
"supplyPlacement": "APPSTORE_SEARCH_RESULTS"
}Tap-through payload example
A payload for tap-through attribution resembles the following:
{
"attribution": true,
"orgId": 40669820,
"campaignId": 542370539,
"conversionType": "Download",
"clickDate": "2024-10-08T17:17Z",
"claimType": "Click",
"adGroupId": 542317095,
"countryOrRegion": "US",
"keywordId": 87675432,
"adId": 542317136,
"supplyPlacement": "APPSTORE_SEARCH_RESULTS"
}View-through payload example
A payload for view-through attribution resembles the following:
{
"attribution": true,
"orgId": 40669820,
"campaignId": 542370539,
"conversionType": "Download",
"impressionDate": "2024-10-08T17:17Z",
"claimType": "Impression",
"adGroupId": 542317095,
"countryOrRegion": "US",
"keywordId": 87675432,
"adId": 542317136,
"supplyPlacement": "APPSTORE_SEARCH_RESULTS"
}Pre-order payload example
A payload for pre-order attribution on tap-throughs resembles the following:
{
"attribution": true,
"orgId": 40669820,
"campaignId": 542370539,
"conversionType": "PreOrder",
"clickDate": "2020-04-08T17:17Z",
"claimType": "Click",
"adGroupId": 542317095,
"countryOrRegion": "US",
"keywordId": 87675432,
"adId": 542317136,
"supplyPlacement": "APPSTORE_SEARCH_RESULTS"
}A payload for pre-order attribution on view-throughs resembles the following:
{
"attribution": true,
"orgId": 40669820,
"campaignId": 542370539,
"conversionType": "PreOrder",
"impressionDate": "2020-04-08T17:17Z",
"claimType": "Impression",
"adGroupId": 542317095,
"countryOrRegion": "US",
"keywordId": 87675432,
"adId": 542317136,
"supplyPlacement": "APPSTORE_SEARCH_RESULTS"
}Attribution payload descriptions
Field | Data type | Description |
|---|---|---|
| long | The identifier for the ad group. [Image]Use Get App Ad Group Reports to correlate your attribution response by |
| long | The identifier representing the assignment relationship between an |
| boolean | The attribution value. A value of |
| long | The unique identifier for the campaign. [Image]Use Get App Campaign Reports in the Apple Ads Platform API to correlate your attribution response by |
| string | For view-through attribution, |
| date/time string | The date and time when the user clicks an ad in a corresponding campaign. [Image]This field only appears in the attribution response payload. |
| string | The type of conversion. Values are |
| string | The country or region for the campaign. [Image]Refer to the |
| UTC string | Represents the date and time when an ad view occurs in a corresponding Apple Ads campaign. The |
| long | The identifier for the keyword. [Image]Use Get App Keyword Reports in the Apple Ads Platform API to correlate your attribution response by |
| long | The identifier of the organization that owns the campaign. Your |
| string | The ad placements for a campaign. |
supplyPlacement descriptions
Value | Description |
|---|---|
| Product page ads on the App Store allow you to reach users browsing app pages, appearing at the top of the “You Might Also Like” list when users scroll to the bottom. |
| Search results ads let you reach users when they search for something specific, with an ad in relevant search results. |
| Search tab ads let you reach users before they search for something specific, with an ad that appears prominently at the top of the suggested apps list on the Search tab. |
| Today tab ads let you reach people on the front page of the App Store, where users start their visit. |