You can write job results from Treasure Data directly to The Trade Desk. In The Trade Desk, you can then distribute advertisements to each DSP targeting segment.


Prerequisites

  • Basic knowledge of Treasure Data, including the TD Toolbelt

  • An account in The Trade Desk  

  • Authorized Treasure Data account access to The Trade Desk

Integration Overview

This integration has two parts:

  1. Cookie-syncing between The Trade Desk DMP and Treasure Data CDP — This is required to create a mapping between The Trade Desk DMP ID and Treasure Data's ID td_global_id.

  2. Data export from Treasure Data CDP into The Trade Desk DMP — Based on the mapping created when you sync cookies, Treasure Data's ID translates segments keyed on their ID into segments keyed on The Trade Desk DMP. Then, you can export the translated segmented data into your The Trade Desk account using the Treasure Data output data connector.

Cookie Syncing between The Trade Desk and Treasure DATA

Data Transfer from Treasure Data to The Trade Desk

Implementing a Cookie-Syncing Tag

You must first set up Treasure Data's JavaScript tag, td_global_id, as illustrated in the previous section and documented in using JavaScript SDK for Cross-Domain Tracking.

Add code similar to the following into the website where The Trade Desk DMP's tag is already installed.

var td = new Treasure({...}); // configure Treasure Data JS SDK
td.set('$global', 'td_global_id', 'td_global_id');
td.trackPageview();
(function(document, td){
  
var successCb(tdGlobalId) {
  // This is createImage in TDWrapper
  var el = document.createElement('img');
  el.src = '//<DMP>.net/usermatch.gif?partner=treasuredata&partner_uid=' + tdGlobalId;
  el.width=1;
  el.height=1;
  el.style.display='none';
  document.body.appendChild(el);
}
  
function isSafari() {
  var ua = window.navigator.userAgent.toLowerCase();
  return ua.indexOf('safari') !== -1 && ua.indexOf('chrome') === -1 && ua.indexOf('edge') === -1;
}

if ( isSafari() ) {
  // Cookie syncing skipped for Safari due to ITP 2.1
} else {
  td.fetchGlobalID(successCb, function(err) { console.log(err) });
}

})(document, td);

Using the TD Console to Create Your Connection

You can use the TD Console to configure your connection.

In The Trade Desk: Getting the Secret Key

Go to Your Advertiser > Preferences and scroll down to get your Secret Key

In Treasure Data: Creating a New Connection

  1. From TD Console, select Integrations Hub.

  2. Select Catalog.

  3. Search for and select the Trade Desk Output connector.

  4. Select Create Authentication.
    The New Authentication dialog opens.
  5. Edit the secret key you obtained from The Trade Desk, and select Continue.
  6. Enter a name for the connection.
  7. Select Done.

The Trade Desk output connector is created.

Configuring Export Results in Your Data Connection

In this step, you create or reuse a query. In the query, you configure the data connection.  In some cases, you must define the column mapping in the query.

Configuring the Connection by Specifying the Parameters

  1. Access the TD Console and navigate to Data Workbench > Queries.
  2. Locate and select the the query that you want to use to export data.
  3. Select Export Results located at top of your query editor.
    The Choose Integration dialog displays.
  4. Enter The Trade Desk connection name in the search box to filter and select your connection.
  5. Specify the parameters: 

Parameters:

  • Advertiser ID (required): Your advertiser ID.

  • Select host name (required): Use the host name closest to the location of users targeted by your campaign. Default TOK (Tokyo)

  • Recency targeting (optional): Recency targeting (optional): A UTC timestamp by which a user, who qualifies for your target audience, is tagged. Omitting this field assumes the user was put into the segment as soon as The Trade Desk processed the data. Alternatively you specify a date and time by which a user is eligible for the data segment. Specify a timestamp in UTC. The format is: yyyy-MM-dd HH:mm. MM represents month (not minute), HH represents 24 hours (not 12). Default : blank

  • Data remains active in a duration of (required): Specify the length of time that a user remains active, as relative to Recency targeting; when the time expires, the data is not used for targeting. Specify the Time-to-live (TTL) in minutes. The time can't be more than 43200 mins (30 days). Minimum time recommended is 2880 mins(48 hours).

  • Max records per batch request (optional): Max Number of records to upload in each batch. Default: 5000

  • Sleep Per API request in Milliseconds (optional): The time, in milliseconds, that the system sleeps for each request. Default : 2000, which is equivalent to 2 seconds.

  • Retry Limit (optional): Number of retries before the system gives up. Default: 7.

 A sample configuration is as follows:


Example Queries to Populate The Trade Desk

From Treasure Data, run the following query with Output results into a connection for The Trade Desk:

Example Query for TDID

SELECT id AS tdid,
name AS dataname
FROM your_table;


Example Query for DAID

SELECT id AS daid,
name AS dataname
FROM your_table;


Example Query for UID2

SELECT id AS uid2,
name AS dataname
FROM your_table;


Example Query for RampID

SELECT id AS rampid,
name AS dataname
FROM your_table;

Using Scheduled Jobs for Output (Optional)

You can use scheduled jobs with Result Output, to periodically write the output result to a target destination that you specify.

Configuring Export Results in Workflow (Optional)

Within Treasure Workflow, you can specify the use of this data connector to output data.

timezone: UTC

_export:
  td:
    database: sample_datasets

+td-result-into-target:
  td>: queries/sample.sql
  result_connection: your_connections_name
  result_settings:
    secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    advertiser_id: xxxxxx
    data_activation_duration: 43200
    ....

Review information on using data connectors in workflow to export data.

Appendix 

Using TD Toolbelt and Your The Trade Desk Connection

You can use TD Toolbelt from the CLI to export to The Trade Desk. 

Example TDID

$ td query --result '{"type":"thetradedesk","secret_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx","advertiser_id":xxxxxx,"data_activation_duration":43200}' -d sample_datasets "SELECT tdid, dataname FROM (\
 VALUES ('d46a3975-c267-404e-89ae-0a9ff0cdce5f','demo-segment'),\
 ('244d97ec-c258-4359-ae80-c67bf92bd294','demo-segment'),\
 ('f749cd45-c6e2-4a82-87fe-afb7d2cd1188','demo-segment')\
) tbl (tdid, dataname)" -T presto

Job xxxxxxxx is queued.
Use 'td job:show xxxxxxxx' to show the status.

Example DAID

$ td query --result '{"type":"thetradedesk","secret_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx","advertiser_id":xxxxxx,"data_activation_duration":43200}' -d sample_datasets "SELECT daid, dataname FROM (\
 VALUES ('d46a3975-c267-404e-89ae-0a9ff0cdce5f','demo-segment'),\
 ('244d97ec-c258-4359-ae80-c67bf92bd294','demo-segment'),\
 ('f749cd45-c6e2-4a82-87fe-afb7d2cd1188','demo-segment')\
) tbl (daid, dataname)" -T presto

Job xxxxxxxx is queued.
Use 'td job:show xxxxxxxx' to show the status.


Example DAID

$ td query --result '{"type":"thetradedesk","secret_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx","advertiser_id":xxxxxx,"data_activation_duration":43200}' -d sample_datasets "SELECT uid2, dataname FROM (\
 VALUES ('48MjlfIUZpOKNAm9nod7/jCLAXUYsnE1tpVHQSDS0uo=','demo-segment'),\
 ('48MjlfIUZpOKNAm9nod7/jCLAXUYsnE1tpVHQSDS0uo=','demo-segment'),\
 ('48MjlfIUZpOKNAm9nod7/jCLAXUYsnE1tpVHQSDS0uo=','demo-segment')\
) tbl (uid2, dataname)" -T presto

Job xxxxxxxx is queued.
Use 'td job:show xxxxxxxx' to show the status.


Example DAID

$ td query --result '{"type":"thetradedesk","secret_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx","advertiser_id":xxxxxx,"data_activation_duration":43200}' -d sample_datasets "SELECT rampid, dataname FROM (\
 VALUES ('XY1005wXyWPB1SgpMUKIpzA0I3UaLEz-2lg0wFAr1PWK7FMhs','demo-segment'),\
 ('XY1005wXyWPB1SgpMUKIpzA0I3UaLEz-2lg0wFAr1PWK7FMhs','demo-segment'),\
 ('XY1005wXyWPB1SgpMUKIpzA0I3UaLEz-2lg0wFAr1PWK7FMhs','demo-segment')\
) tbl (rampid, dataname)" -T presto

Job xxxxxxxx is queued.
Use 'td job:show xxxxxxxx' to show the status.
  • No labels