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

Integration Overview

This integration has two parts:

  1. Cookie-syncing between The Trade Desk DMP and Treasure Data CDP: Required to create a mapping between The Trade Desk DMP ID and Treasure Data ID's 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 our output data connector.

Cookie Syncing

Data Transfer Treasure Data to The Trade Desk

Implement 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);

Use the TD Console to Create Your Connection

You can use the TD Console to configure your connection.

In The Trade Desk

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

Create a New Connection

  1. From TD Console, select Integrations Hub.

  2. Select Catalog.

  3. Search for and select theTradeDesk.


  4. The following dialogue opens.


  5. Edit the required Secret Key. Select Continue.


  6. Name your new connection.

Configure 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.

Configure the Connection by Specifying the Parameters

Access TD Console and navigate to the query editor. Access the query that you plan to use to export data.

Select Output Results located at top of your query editor. The Choose Saved Connection dialog opens. Type the connection name in the search box to filter and select your connection.

Specify the parameters: 

Parameters:

 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:

Code Example for TDID

SELECT id AS tdid,
name AS dataname
FROM your_table;


Code Example for DAID

SELECT id AS daid,
name AS dataname
FROM your_table;

Optionally Use Scheduled Jobs for Output

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

Optionally Configure Export Results in Workflow

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 

Use 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.