You can write job results directly to your Instagram Custom Audience. Instagram is part of Facebook so these instructions include references to Facebook technical specifications.
A Custom Audience is an ad targeting option that lets you find your existing audiences among people who are on Instagram. You can use sources like customer lists, website or app traffic, or engagement on Facebook, to create Custom Audiences of people who already know your business.
You can create:
- Website Custom Audiences
- App Activity Custom Audience
- Customer List Custom Audience
- Engagement Custom Audiences
- Basic knowledge of Treasure Data, including the TD Toolbelt.
- An Instagram Ad Account
- A Business Profile for Instagram
- Authorized Treasure Data Facebook application access to your own Instagram Ad Account
Treasure Data result output normalizes your values automatically to follow Facebook’s normalizing rules, see here.
All values, uploaded to Facebook for matching, must be normalized with the normalizing rules of Facebook. The values will just miss chances to match if they are not normalized. If you need to normalize the data manually, apply your own normalization before attempting to output results.
The following conversion behavior is applied according to data type during result output for normalization.
EXTERN_ID (External ID): no action needed.
EMAIL (Email addresses): trimming leading and trailing whitespace and convert all characters to lowercase.
PHONE (Phone numbers): removing any non-digit characters and leading zeros.
GEN (Gender): trimming leading and trailing whitespace and convert all characters to lowercase. If the result does not match with “m” or “f”, an empty string will be used (because it’s an invalid value, there is no use to match it)
DOBY (Birth Year): removing any non-digit characters and get the first 4 digits.
DOBM (Birth Month) and DOBD (Birthday): removing any non-digit characters and get the first 2 digits.
FN (First Name) and LN (Last Name): trimming leading and trailing whitespace and convert all characters to lowercase. Remove all punctuation. Supports special characters in UTF-8 encoding.
FI (First Initial): apply the same as First Name and get the first character.
CT (City): convert all characters to lowercase and remove any non-alphabetic (a-z) characters.
ST (States): convert all characters to lowercase and remove any non-alphanumeric (a-z and 0-9) characters.
- Note: If your value is US State, use 2-character ANSI abbreviation code, the Treasure Data platform does not cut off input string (into 2 characters), because of the need to support states outside the US.
ZIP (Zipcode): trimming leading and trailing whitespace and convert all characters to lowercase, remove any nonalphanumeric or whitespace from the result.
- Note: If your value is US zip code, use exactly 5 digits, our the Treasure Data platform does not cut off input string (into 5 characters), because of the need to support UK zip code format.
LOOKALIKE_VALUE: Long or double value; a null or empty value will be sent as 0. The column is supported by value-based Custom Audience only.
In Treasure Data, you must create and configure the data connection prior to running your query. As part of the data connection, you provide authentication to access the integration.
- Open TD Console.
- Navigate to Integrations Hub > Catalog.
- Search for and select Custom Audiences.

Select Create Authentication.

Accept the connection or select Click here.
Optionally, follow the prompts to log into a different Facebook account.

You will be redirected back to the Catalog. Repeat the first step (Create a new connection) and choose your new OAuth connection.
- Select Continue.
- Name the connection.
- Select Done.
The column name is case-insensitive, ie. you can use email or EMAIL.
Here is an example Audiences list before the output of a query result:

From Treasure Data, run the following query with Output results into a connection of Instagram Custom Audience (see details of column naming):
SELECT email, fn, ln FROM (
VALUES ('demo1@example.com', 'John', 'Doe'),
('demo2@example.com', 'Isaac', 'Miceli'),
('demo3@example.com', 'Christopher', 'Agar')
) tbl (email, fn, ln)The above query will not match any real users, it’s for demo purposes only. Also, the query requires no source table (for the ease of testing out this feature), but you still must choose a database, so pick “sample_datasets” or any other arbitrary table. The query should complete in a few seconds. After that, check your Audience List:

The output result needs to follow the Facebook User schema. The column name is case-insensitive, ie. you can use email or EMAIL. Supported column names are:
- EXTERN_ID: External ID
- EMAIL: Email addresses
- PHONE: Phone numbers
- GEN: Gender
- DOBY: Birth Year
- DOBM: Birth Month
- DOBD: Birthday
- LN: Last Name
- FN: First Name
- FI: First Initial
- CT: City
- ST: States
- ZIP: Zip code
- MADID: Mobile advertiser id
- COUNTRY: Country code
- LOOKALIKE_VALUE: value for value-based lookalike audience
If no supported column is found from the query result, an error is thrown.
See Exporting Results using Export Integration.

| Parameter | Values | Description |
|---|---|---|
| Ad Account ID | required | This is your Ad Account ID without act_ prefix |
| API Version | optional, default v2.11 | Facebook/Instagram API Version, it’s best to keep the default value. |
| Action | Add Remove Replace | - Add: Add records to Custom Audience - Remove: remove records from Custom Audience - Replace: replace records in Custom Audience. A limit of one job replacing a custom audience can be in process at any time. After the job finishes on the TD side, it takes some additional time on the Instagram side. During that time other users can't replace that custom audience. |
| Custom Audience Name | required | Name of Custom Audience to create/update, if none exists, one will be created. - Important note: If you have any Custom Audiences with the same name as this input, the latest one will be used. We recommend giving your Custom Audience a unique name |
| Custom Audience Description | optional | Description of Custom Audience. |
| Page ID | Optional | The PAGE ID used by the users being uploaded. Required when the schema is a Facebook UID and the IDs were collected by a Page webhook integration. |
| Source of customer data | User Partner Both | Specify the source of the user information collected into this file. |
| No need to normalize and hash records | true false | Indicates whether the data has already been normalized and hashed. If not, TD automatically normalizes and hashes the records. |
| Initial intervals in milliseconds between retries | optional, default 60000 | Interval to retry if a recoverable error happens (in millisecond). |
| Retry limit | optional, default 5 | Number of retries before it gives up. |
SELECT typeof(online_followers_lifetime) FROM instagram_test_insight_1 WHERE online_followers_lifetime <> '0';You can use an alias in your query to rename columns of your query result, for example:
SELECT an_email_column AS EMAIL,
another_phone_column AS PHONE
FROM your_table;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.
Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically exported to the specified destination.
Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications.
(Optional) You can delay the start time of a query by enabling the Delay execution.
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.
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.
After you output your user list into an Instagram Custom Audience,
- Open Facebook/Instagram Ads Manager to edit the ad placement. By default, Facebook will choose to display within Instagram Ads.
- Automatic Placements (default):

- Edit Placement:
