Amazon Demand-Side Platform (DSP) enables advertisers to programmatically buy display, video, and audio ads on or off Amazon. Amazon DSP is available to advertisers on Amazon irrespective of whether they sell products on Amazon. You can use Amazon's DSP to reach audiences through Amazon sites, apps, publishing partners, and third-party exchanges.
The Amazon DSP Data Provider Export Integration allows you to export segment data like hashed emails and customer information to Amazon DSP.
- Basic knowledge of Amazon DSP and an advertiser account.
- Basic Knowledge of Treasure Data functions like Authentication, Queries, Results Export, and (optionally) Workflow.
- The
External Audience IDis the key to specifying the target audiences on Amazon. (It is unique to all audiences.) The values of this field will be unique for each advertiser account. - The job may split the result set into multiple batches. If one batch fails, the integration will not revert the successfully uploaded batches.
- The integration will add the prefixes required per Amazon DSP API (COOKIE- or MAID-). Do not add these prefixes manually in the result set.
- The integration will not update the Audience Metadata.
- Null or empty column data will be ignored.
- The result output schema must have either the cookie or maid columns or both in their metadata.
Maidandcookiecolumns must have thestringdata type.- The maximum length for a
cookiefield is 1999 characters. - For PII data export to Amazon DSP, we recommend using Amazon Ads Export Integration. This connector uses a different API pathway and may yield better match performance.
If your security policy requires IP whitelisting, you must add Treasure Data's IP addresses to your allowlist to ensure a successful connection.
Please find the complete list of static IP addresses, organized by region, at the following link:
https://api-docs.treasuredata.com/en/overview/ip-addresses-integrations-result-workers/
- Prepare a Hashed Records Datasource, including an external identifier
- External identifier (external_id): A unique id represents a customer profile for a target advertiser. Using a hashed number generated from a combination of the advertiser ID and email (or phone) is recommended. If multiple customer profiles use the same external identifier (,.e. ID: 12345), it will be overwritten in the matching process in Amazon DSP, resulting in a low matching rate. Example of generating the external_id using the combination of advertiser_id and email:
- External_id is the combination of advertiser_id and email:
SELECT
TO_HEX(SHA256(TO_UTF8(CONCAT(advertiser_id, email)))) AS external_id
FROM
table_name;- In the data connector configuration, select the
hashed recordsdata source to send the above data to Amazon DSP for matching. - The matching process will begin within the Amazon DSP. The SLA (Service Level Agreement) is set at 48 hours. This timeframe starts when the hashed record API is called to utilize the uploaded external IDs for audience creation. It is important to note that the SLA remains consistent and does not change regardless of the volume of records being processed.
- Add to Audience or Remove from Audience:
- Prepare an external_user_id table for the audience to be added or removed from. The external_user_id is the external_id in step 1
SELECT
external_id as external_user_id
FROM
TABLE_NAME- Then, export the result by selecting the ‘Audiences' data source.
In Treasure Data, before running your query, you must create and configure the data connection to be used during the export. As part of the data connection, you provide authentication to access the integration.
- Login to TD Console.
- Navigate to Integrations Hub > Catalog.
- Select the search icon on the far right of the Catalog screen, and enter Amazon DSP.
- Hover over the Amazon DSP Data Provider connector and select Create Authentication.
Alternatively. create an activation (which includes authentication information) in TD Console.
The following dialog opens:

- Choose the Region of your advertiser account.
- Enter your Advertiser ID. Then select Continue.
- Enter a name for your connection.
- Select Done.

- Navigate to Data Workbench > Queries.
- Select New Query.
- Run the query to validate the result set.

- Select Export Results.

- You can select an existing authentication or create a new authentication for the external service to be used for output. Choose one of the following:
The Amazon DSP Data Provider data connector understands and interprets only the following columns and data types. It would be best if you modified alias column names to match the following specified columns:
Data Source: Audiences (require at least one of the below columns)
| Column name | Type | Required | Description |
|---|---|---|---|
| cookie | string | optional | a cookie Id sent from a data provider to Amazon by a cookie sync |
| maid | string | optional | a mobile advertising identifier |
| external_user_id | string | optional | an external id defined by data providers |
Data Source: Hashed_records (all below columns are required)
| Column name | Type | Required | Description |
|---|---|---|---|
| first_name | string | required | The first name |
| last_name | string | required | The last name |
| address | string | required | The street address |
| phone | string | required | The phone number |
| city | string | required | The city |
| postal_code | string | required | The postal code |
| state | string | required | The state or province |
| string | required | The email address | |
| external_id | string | required | The external identifier for this record |
To export results:
- Log into TD Console.
- Navigate to Data Workbench > Queries.
- Select the query that you plan to use to export data.
- Example Audience Datasource:
SELECT
a_cookie_column AS cookie,
a_maid_column AS maid
FROM
your_table;Example Hashed Records Datasource: Note that all columns are required; you can use dummy data strings for fields where you do not have data. E.g "first_name", "last_name_column". (Do not use empty strings "")
SELECT
first_name_column AS first_name,
last_name_column AS last_name,
address_column AS address,
phone_column AS phone,
city_column AS city,
postal_code_column AS postal_code,
state_column AS state,
email_column AS email,
external_id_column AS external_id
FROM
your_table- Select Export Results, located at the top of your query editor.
- The Choose Integration dialog box opens.
- You have two options when selecting a connection to use to export the results:
- Use an Existing Integration
- Create New Integration
- Type the connection name in the search box to filter.
- Select your connection.

- Select Next.
- Type values for Audience Name, Audience Description, External Audience ID, Time to live, and Operation, and Ignore Invalid Records.
- Select Create New Integration.
- Type a Name for your connection.
- Select your region.
- Enter your Advertiser ID.

- Select Next.
- Enter values for the Audience Name, Audience Description, External Audience ID, Time to live, Data Source Country, Operation, and Ignore Invalid Records fields**.
- Select **Done.**

| Parameter | Description |
|---|---|
| Data Source (required) | The data source could be audiences or hashed_records. |
| Audience Name (required if the data source is audiences) | The name of the audience you would like to create. |
| Audience Description (optional) | Description for your audience. |
| External Audience ID (required if the data source is audiences) | Unique key for your audience. |
| Time to live (required if the data source is audiences) | The time in seconds that the audience will stay valid. |
| Data Source Country (required) | Country codes are where your audience data is collected. Examples: "DE," "JP," etc. The DMA (Digital Markets Acts) requires this. From February 29, 2024, all audience creation/update requests should contain the field indicating where the audience data was collected. |
| Operation (required if the data source is audiences) | The operation to perform on output data (add or remove). |
| Ignore Invalid Records | If this check box is selected when the time data is sent to Amazon DSP, incorrect records or errors are skipped, and the remaining rows of data continue sending. If this checkbox is not selected, an exception is thrown when inaccurate records or errors are encountered. |
You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify.
Treasure Data's scheduler feature supports periodic query execution to achieve high availability.
When two specifications provide conflicting schedule specifications, the specification requesting to execute more often is followed while the other schedule specification is ignored.
For example, if the cron schedule is '0 0 1 * 1', then the 'day of month' specification and 'day of week' are discordant because the former specification requires it to run every first day of each month at midnight (00:00), while the latter specification requires it to run every Monday at midnight (00:00). The latter specification is followed.
Navigate to Data Workbench > Queries
Create a new query or select an existing query.
Next to Schedule, select None.

In the drop-down, select one of the following schedule options:

Drop-down Value Description Custom cron... Review Custom cron... details. @daily (midnight) Run once a day at midnight (00:00 am) in the specified time zone. @hourly (:00) Run every hour at 00 minutes. None No schedule.

| Cron Value | Description |
|---|---|
0 * * * * | Run once an hour. |
0 0 * * * | Run once a day at midnight. |
0 0 1 * * | Run once a month at midnight on the morning of the first day of the month. |
| "" | Create a job that has no scheduled run time. |
* * * * *
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +---------- month (1 - 12)
| | +--------------- day of month (1 - 31)
| +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)The following named entries can be used:
- Day of Week: sun, mon, tue, wed, thu, fri, sat.
- Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec.
A single space is required between each field. The values for each field can be composed of:
| Field Value | Example | Example Description |
|---|---|---|
| A single value, within the limits displayed above for each field. | ||
A wildcard '*' to indicate no restriction based on the field. | '0 0 1 * *' | Configures the schedule to run at midnight (00:00) on the first day of each month. |
A range '2-5', indicating the range of accepted values for the field. | '0 0 1-10 * *' | Configures the schedule to run at midnight (00:00) on the first 10 days of each month. |
A list of comma-separated values '2,3,4,5', indicating the list of accepted values for the field. | 0 0 1,11,21 * *' | Configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month. |
A periodicity indicator '*/5' to express how often based on the field's valid range of values a schedule is allowed to run. | '30 */2 1 * *' | Configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. '0 0 */5 * *' configures the schedule to run at midnight (00:00) every 5 days starting on the 5th of each month. |
A comma-separated list of any of the above except the '*' wildcard is also supported '2,*/5,8-10'. | '0 0 5,*/10,25 * *' | Configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month. |
- (Optional) You can delay the start time of a query by enabling the Delay execution.
Example Audience Datasource
timezone: UTC_export: td: database: sample_datasets+td-result-into-target: td>: queries/sample.sql result_connection: your_connections_name result_settings: datasource: audiences region: NA advertiser_id: 12345 audience_name: This is a test audience audience_description: This is for testing purpose external_audience_id: test_audiences time_to_live: 3600 data_source_country: GB,IN,DE operation: Add ignore_error: falseExample Hashed Records:
timezone: UTC
_export:
td:
database: sample_datasets
+td-result-into-target:
td>: queries/sample.sql
result_connection: your_connections_name
result_settings:
datasource: hashed_records
region: NA
advertiser_id: 12345
time_to_live: 3600
ignore_error: false To learn more about using data connectors in a workflow, refer to the Workflows section of the documentation.
You can also send segment data to the target platform by creating an activation in the Audience Studio.
- Navigate to Audience Studio.
- Select a parent segment.
- Open the target segment, right-mouse click, and then select Create Activation.
- In the Details panel, enter an Activation name and configure the activation according to the previous section on Configuration Parameters.
- Customize the activation output in the Output Mapping panel.

- Attribute Columns
- Select Export All Columns to export all columns without making any changes.
- Select + Add Columns to add specific columns for the export. The Output Column Name pre-populates with the same Source column name. You can update the Output Column Name. Continue to select + Add Columnsto add new columns for your activation output.
- String Builder
- + Add string to create strings for export. Select from the following values:
- String: Choose any value; use text to create a custom value.
- Timestamp: The date and time of the export.
- Segment Id: The segment ID number.
- Segment Name: The segment name.
- Audience Id: The parent segment number.
- + Add string to create strings for export. Select from the following values:
- Set a Schedule.

- Select the values to define your schedule and optionally include email notifications.
- Select Create.
If you need to create an activation for a batch journey, review Creating a Batch Journey Activation.
You can also use TD Toolbelt CLI to export results to Amazon DSP.
It would be best to specify the information for export to your Amazon DSP server using the --result option of the td query command. For more information about td query, refer to TD Toolbelt Query Commands.
The format of the option is JSON, and the general structure is as follows:
{"type": "amazon_dsp_dp", "region": "NA", "advertiser_id": "12345", "audience_name": "This is a test audience", "audience_description": "This is for testing purpose", "external_audience_id": "test_audiences", "time_to_live": 3600, "data_source_country": "GB, IN, DE", "ignore_error": false}