The Attribution API is for sending attribution campaign events (identified by idfa
, idfv
, or adid
) that contain attribution information.
This API uses your API key passed as a query parameter in the URL of the request:
https://api2.amplitude.com/attribution?api_key=API_KEY
For more information, see Find your API Credentials
Region | Endpoint |
---|---|
Standard server | https://api2.amplitude.com/attribution |
EU residency server | https://api.eu.amplitude.com/attribution |
idfa
, idfv
, and adid
fields in Amplitude as the Advertising ID.Send a POST
request to https://api2.amplitude.com/attribution with two arguments: api_key
and event
.
Name | Description | Example |
---|---|---|
api_key |
Required. The project's API key. | api_key |
event |
Required. A request parameter representing the event, in JSON format. | {"event_type":"[YOUR COMPANY] Install", "idfa": "AEBE52E7-03EE-455A-B3C4-E57283966239", "user_properties": {"[YOUR COMPANY] media source": "facebook", "[YOUR COMPANY] campaign": "refer-a-friend"}, "platform": "ios"} |
These keys are available for the Event argument.
Key |
Description | Example |
---|---|---|
event_type |
Required. String. The event info. Prefix with brackets [YOUR COMPANY] . |
[YOUR COMPANY] Install |
platform |
Required. String. Either ios or android . |
ios |
idfa or idfv |
Required for iOS. String. The Identifier for Advertiser or the Identifier for Vendor. You must include at least one for iOS devices. | AEBE52E7-03EE-455A-B3C4-E57283966239 |
adid |
Required for Android. String. The Google ADID, or Amazon Advertising ID for Amazon devices. | AEBE52E7-03EE-455A-B3C4-E57283966239 |
android_id |
Optional. String. (Android) The Android ID | AEBE52E7-03EE-455A-B3C4-E57283966239 |
user_properties |
Optional. Dictionary. A dictionary of attribution properties prefixed with brackets [YOUR COMPANY] . |
{"[YOUR COMPANY] media source": "Facebook"} |
time |
Optional. Long. Timestamp of the event in milliseconds since epoch. | 1396381378123. It's set to the upload time by default |
The following code illustrates attribution for iOS.
1curl --location --request POST 'https://api.amplitude.com/attribution' \2--data-urlencode 'api_key=123456789' \3--data-urlencode 'event={"event_type":"[YOUR COMPANY] Install", "idfa": "AEBE52E7-03EE-455A-B3C4-E57283966239", "user_properties": {"[YOUR COMPANY] media source": "facebook", "[YOUR COMPANY] campaign": "refer-a-friend"}, "platform": "ios"}'
1POST /attribution HTTP/1.12Host: api.amplitude.com3Content-Length: 3654 5api_key=&event=%7B%22event_type%22%3A%22%5BYOUR%20COMPANY%5D%20Install%22%2C%20%22idfa%22%3A%20%22AEBE52E7-03EE-455A-B3C4-E57283966239%22%2C%20%22user_properties%22%3A%20%7B%22%5BYOUR%20COMPANY%5D%20media%20source%22%3A%20%22facebook%22%2C%20%22%5BYOUR%20COMPANY%5D%20campaign%22%3A%20%22refer-a-friend%22%7D%2C%20%22platform%22%3A%20%22ios%22%7D
The following example illustrates attribution on Android.
1curl --location -g --request POST 'https://api2.amplitude.com/attribution?api_key=123456789&event={"event_type":"[YOUR COMPANY] Install","adid": "AEBE52E7-03EE-455A-B3C4-E57283966239", "user_properties": {"[YOUR COMPANY] media source": "facebook", "[YOUR COMPANY] campaign": "refer-a-friend"}, "platform": "android"}'
1POST /attribution?api_key=api_key&event="{event_type":"[YOUR COMPANY] Install","adid": "AEBE52E7-03EE-455A-B3C4-E57283966239", "user_properties": {"[YOUR COMPANY] media source": "facebook", "[YOUR COMPANY] campaign": "refer-a-friend"}, "platform": "android"} HTTP/1.12Host: api2.amplitude.com
Code | Message |
---|---|
200 | Success |
400 | The expected JSON is formatted incorrectly. |
Thanks for your feedback!
May 21st, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.