# Criteo Export Integration You can write job results from Treasure Data directly to Criteo Marketing API. Criteo provides creative ad control, targeting options, and media buying all in one platform. ## Prerequisites - Basic knowledge of Treasure Data, including the [TD Toolbelt](https://toolbelt.treasuredata.com/) - A Criteo Marketing API account - Authorized Treasure Data account access to Criteo ## Use the TD Console to Create Your Connection ### Create a New Connection You must create and configure the data connection in Treasure Data before running your query. As part of the data connection, you provide authentication to access the integration. 1. Open the **TD Console** 2. Navigate to the **Integrations Hub** > **Catalog** 3. Click the search icon on the far right of the Catalog screen and enter Criteo. 4. Hover over the Criteo integration and select **Create Authentication**. 5. Select Continue ![](/assets/image2021-7-9_13-52-6.86dece86f4a8bc57a5b5352b764159de85bbff18147e330ac5f7758a2990dd6c.2959d308.png) 1. Name your connection. 2. Select Done. 3. Contact Support to provide a consent URL (Ex: [https://consent.criteo.com/request?nonce=xxxxxxxxxx&hmac=xxxxxxxxxx](https://consent.criteo.com/request?nonce=xxxxxxxxxx&hmac=xxxxxxxxxx)). 4. You must open this link on a browser. 5. Grant access to advertisers like this. 6. Approve the change. ![](/assets/image2021-6-30_17-32-40.754e49c21d421e77d13c83ee426895b16db049f6059b598bfbb70eaa363ecd48.2959d308.png) ## Obtain Your Advertiser ID This ID is required to export your data to Criteo. 1. Login into [https://account.criteo.com/auth/XUI/criteo-login/](https://account.criteo.com/auth/XUI/criteo-login/) 2. Select the Management Center. ![](/assets/image2021-6-30_17-36-25.16620cb769e17967bf08d9f9a01511d963d9622be66d9bc2ae8eab250004ec06.2959d308.png) 1. Retrieve the advertiser ID from the URL. For example: ![](/assets/image2021-6-30_17-39-50.9942b821243911a356c3b011b3a9c7de05af78e2ab28ed4f7d5273370a0813b7.2959d308.png) ## Define your Query Sometimes you need to define the column mapping in the query. 1. Complete the instructions in [Creating a Destination Integration](https://docs.treasuredata.com/display/PD/Creating+a+Destination+Integration). 2. Navigate to **Data Workbench > Queries**. 3. Select a query for which you would like to export data. 4. Run the query to validate the result set. 5. Select**Export Results**. 6. Select an existing integration authentication. ![](/assets/criteo-export-integration-2024-01-19.b765386a6d098ed63694466829a5d26ab945c434fe9a6c9b97d7237f2e2df929.2959d308.png) 7. Define any additional Export Results details. In your export integration content review the integration parameters. 8. Select **Done**. 9. Validate that your data moved to the destination you specified. ## Column Naming Data exported to Criteo must follow the Criteo schema. Supported column names are: - id: The audience segment ID - name: The audience segment name - operation: The operation (add or remove) to perform on an audience segment - schema: The type of identifier represented in the row of data. Support identifier values include gum, email, madid, and identityLink - userid: The identifier to add or remove from an audience segment - gumid: The GUM caller ID, data required for gum schema. In this case, you must specify `359` because the caller is TreasureData. Example: ```sql SELECT audience_segment_id_column AS id, audience_segment_name_column AS name, 'add' AS OPERATION, 'gum' AS SCHEMA, {criteo_id} AS userid, 359 AS gumid FROM your_table ``` ## Integration Parameters for Criteo ![](/assets/image2021-7-9_14-27-38.5e8ec288f4122788bc0c60261db00796f74e66b90895cfd39f78c106c6200942.2959d308.png) | Parameter | | Description | | --- | --- | --- | | **Advertiser ID** | required | The ID is used to group audiences. | | **Maximum Identities Per Request** | optional Default: 50000 | The maximum number of IDs to include per request. The maximum number for the Criteo interface is 50000. | | **Retry Limit** | optional Default: 7 | The number of times to attempt a network operation. | | **Connect Timeout in Seconds** | optional Default: 300 | The time, in seconds, to wait until aborting a connection operation. Default: 300, which is equivalent to 5 minutes. | | **Read Timeout in Seconds** | optional Default: 900 | The time, in seconds, to wait until aborting a read operation. Default: 900, which is equivalent to 15 minutes. | | **Write Timeout in Seconds** | optional Default: 900 | The time, in seconds, to wait until aborting a write operation. Default: 900, which is equivalent to 15 minutes. | ## Example Query ``` SELECT audience_id_column AS id, audience_name_column AS name, operation_column AS operation, schema_column AS schema, userid_column AS userid, gumid_column AS gumid FROM your_table ; ``` The following is a sample configuration: ![](/assets/criteoexport.00c81a2e4b7bf05f138fcbd56b7c4e7b436373306681b5560ffd6025161cdef2.2959d308.jpg) ### (Optional) Schedule Query Export Jobs 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. #### Scheduling your Job Using TD Console 1. Navigate to **Data Workbench > Queries** 2. Create a new query or select an existing query. 3. Next to **Schedule**, select None. ![](/assets/image2021-1-15_17-28-51.f1b242f6ecc7666a0097fdf37edd1682786ec11ef80eff68c66f091bc405c371.0f87d8d4.png) 4. In the drop-down, select one of the following schedule options: ![](/assets/image2021-1-15_17-29-47.45289a1c99256f125f4d887e501e204ed61f02223fde0927af5f425a89ace0c0.0f87d8d4.png) | Drop-down Value | Description | | --- | --- | | Custom cron... | Review [Custom cron... details](#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. | #### Custom cron... Details ![](/assets/image2021-1-15_17-30-23.0f94a8aa5f75ea03e3fec0c25b0640cd59ee48d1804a83701e5f2372deae466c.0f87d8d4.png) | **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. | 1. (Optional) You can delay the start time of a query by enabling the Delay execution. ## Optionally Configure Export Results in Workflow Within Treasure Workflow, you can specify the use of this data connector to export data. Learn more at [Using Workflows to Export Data with the TD Toolbelt](https://docs.treasuredata.com/smart/project-product-documentation/treasure-workflow-quick-start-using-td-toolbelt-in-a-cli). Within Treasure Workflow, you can specify the use of the data connector to output data. ```yaml timezone: UTC _export: td: database: sample_datasets +td-result-into-criteo: td>: queries/sample.sql result_connection: your_connections_name result_settings: advertiser_id: 12345 request_threshold: 50000 request_retries: 7 request_connect_timeout: 300 request_read_timeout: 900 request_write_timeout: 900 ``` ## FAQs for Criteo Export Q: Where do I confirm audience segment ID? - To confirm audience segment ID, check with the tool provided by Criteo. [https://marketing.criteo.com/audiences?advertiserId={advertiserId}](https://api.criteo.com/marketing/swagger/ui/index#!/Audiences/Audiences_GetAudiences) Q: Are both the audience segment ID and audience segment name required to not be NULL? - No. Either the audience segment ID or audience segment name must be non-NULL, not both. If the audience segment ID and audience segment name are both provided, then the values must be present within the same audience segment. Q: If audience segment ID or audience segment name do not exist in the list of audience-segments, will they be created? - If an audience segment name is provided and the audience segment ID is NULL, an audience segment is created if the audience segment name is not found in the list of audience-segments. - If an audience segment ID is provided, an audience segment cannot be created if the audience segment ID is not found in the list of audience-segments. The Criteo API does not allow the audience segment ID to be specified when creating an audience segment. Q: How long does it take for my audience segment to be updated when adding or removing users? - Criteo can take up to 24 hours to process the data and make it available for display. The data is stored in Criteo's system but takes some time to be processed. Q: How do I check upload result? - Check with tool provided by Criteo (https://marketing.criteo.com/audiences?advertiserId={advertiserId}). ## FAQs for Log Messages Q: Log: Columns [] were not found. - The column names listed in the message were missing from the query. - Check the query to ensure that the column names are not missing or they are not misspelled. Q: Log: Created audience id 'id' for audience name 'name' - The audience segment name was not found within the list of audience segments for the advertiser ID provided. The audience segment is created only if the name does not exist and the ID value provided by the query is NULL. Q: Log: Audience id 'id' is not found in the list of audiences for advertiser 'id'. Cannot create a new audience for non-existent id - If the audience segment ID value provided by the query is not NULL and the audience segment ID does not exist within the list of audience segments for the advertiser ID provided, then the audience segment cannot be created by the connector. The audience segment ID provided does not match the audience segment ID generated by the Criteo API and causes a data mismatch. - Create an audience segment and update data entries of unknown audience segment IDs with newly created audience segment IDs. Q: Log: Audience name 'name' is not found in the list of audiences for advertiser 'id' but audience id 'id' is found. Cannot create a new audience due to name mismatch - Both the audience segment ID and name were provided by the query but the audience segment name was not found in the list of audience segments for the advertiser ID provided. Providing the name as part of the Criteo API operation is invalid. - Make the name NULL in the database or update the audience segment name to match the name provided by the query. Q: Log: Audience id 'id' and audience name 'name' do not represent the same audience for advertiser 'id' - The audience segment name associated with ID does not match the audience segment name provided by the query. - If both the audience segment ID and name are provided by the query and are not NULL, both values must be associated with the same audience segment. You can update the audience segment name associated with the ID to match the name provided by the query or you can modify the row of data and set the name to match the name value within the audience segment.