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: 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:

  • 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: 1000

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

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

  • Initial retry time wait in milliseconds (optional): The time, in milliseconds, between the first and second attempt. Default: 30000, which is equivalent to 30 seconds.

  • Max retry wait in milliseconds (optional): The time, in milliseconds, between the second and all subsequent attempts. Default: 120000, which is equivalent to 2 minutes.

  • HTTP Connect Timeout (optional): The time, in milliseconds, HTTP connect timeout. Default: 60000, which is equivalent to 1 minutes.

  • HTTP Read Timeout (optional): The time, in milliseconds, HTTP read timeout. Default: 300000, which is equivalent to 5 minutes.

  • Fail job if there are invalid records (optional): If selected, the job fails when invalid records are found during uploading. Default: unchecked

 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.



  • No labels