You can connect Salesforce with Treasure Data for greater control over your Salesforce data and better integration with the other business applications in your marketing and sales operations stack. Integrating Salesforce with Treasure Data makes it easy to:
- Add new features to Salesforce. For example, you can prevent churn by tracking web usage and receiving alerts when customers’ product usage declines.
- Use Salesforce data to improve other parts of your marketing stack. For example, you can increase your Facebook Ads ROI by automatically removing new customers from your Facebook Custom Audiences.
For sample workflows on exporting data from Salesforce, go to Treasure Boxes.
If you don’t have a Treasure Data account yet, contact us so that we can get you set up.
A front-end application streams data to be collected in Treasure Data via Log/data collector daemon or Mobile SDKs. You can also bulk import your data using Bulk Import from the CLI. A scheduled query is setup in Treasure Data to run periodically on the data and write the result of each query execution into your Salesforce.com Object. The following is a fairly common architecture, for example:

Every social/mobile application calculates the “top N of X” (ex: top 5 movies watched today). Treasure Data already handles the raw data warehousing; the write-to-salesforce.com” feature enables Treasure Data to find the “top N” data as well.
If you’re a data scientist, you need to keep track of a range of metrics every hour/day/month and make them accessible via visualizations. Using this “write-to-Salesforce.com” feature, you can streamline the process and focus on building visualizations of your query results via Reports and Dashboards on the Salesforce.com organization.
- Basic knowledge of Treasure Data, including the TD Toolbelt.
- Salesforce.com organization and username, password, and security token for API integration.
- You have “API Enabled” permission.
- Target Salesforce.com Object should exist with read and write permissions.
SFDC output supports these authentication types:
- Credential
- Session
Connecting to Salesforce using the TD Console is quick and easy. Alternatively, create a Salesforce connection using the command line. The export integration supports credentials; you need a client ID and client secret to authenticate using credentials.
These instructions guide you to locate the client ID and client secret that is necessary to authenticate using credentials.
his is the guide for Lightning Experience UI.
- Go to Setup >Apps > App Manager.
- Select New Connected App.
- Set some values and check Enable OAuth Settings. Then, grant OAuth permission scope.
4. Click Save. Activation can take up to 10 minutes. 5. Go to Setup > Apps > App Manager. 6. Locate the connected app, click ▼, and then select View.
7. Write down or copy your Consumer Key (client_id) and Consumer Secret (client_secret).
8. For secure account access, get a Salesforce Security Token. If you don’t have a security token, go to Account > Settings > Reset My Security Token and select Reset Security Token. You’ll receive your Security Token by email.
In Spring 19 classic UI: My account > My Settings > Personal > Reset My Security Token.
- Open TD Console.
- Navigate to Integrations Hub > Catalog.
- Search for Salesforce.
4. To authenticate with Credentials
- To authenticate with your credentials, enter your username (your email) and password, as well as your Client ID, Client Secret, and Security Token.
- In the dialog box, enter login.salesforce.com as the login URL. Remove unnecessary letters from Login URL parameter.

- Select Continue.
- Give your connection a descriptive name and select Create Connection.
To validate the user permission, make sure to use Salesforce to validate:
- Authority: check the Salesforce export integration connection steps.
- Allowed access to Salesforce from Treasure Data: sometimes configuring this requires knowing and configuring your TD static IP address. Please contact support if you require the static IP address information.
Without properly configured authority and access, you might encounter access restriction errors. For example:
Response not 2xx:
400 Bad Request {"error":"invalid_grant","error_description":"authentication failure"}Define your Query
Select a database and table from the popup menus. Enter your query and select Output results.
To avoid any issues with result export, define column aliases in your query such that resulting column names from the query match the Salesforce field names for default fields and API names (usually ending with __c) for custom fields.

| Parameter | Description |
|---|---|
| Object | Salesforce.com Object |
| Mode | - The append mode is the default that is used when no mode option is provided in the URL. In this mode, the query results are appended to the object. - With the truncate mode, the system first truncates the existing records in the Salesforce.com Object and moves them into the Trashbin, then inserts the query results. - With the update mode, a row is inserted unless it would cause a duplicate value in the external key columns specified in the “unique” parameter. In such a case, an update is performed instead. The “unique” parameter is required with this mode and must be defined as an external key when used with the update mode. |
| Concurrency mode | The concurrency_mode option controls how the data is uploaded to the Salesforce.com organization. The default mode is parallel. With the parallel method, data is uploaded in parallel. This is the most reliable and effective method for most situations. if you see “UNABLE_TO_LOCK_ROW” in an error message, try concurrency_mode=serial instead. |
| Retry Limit | This option sets the number of attempts made to write the result to the configured Salesforce.com destination if errors occur. If the export fails more than the set number of retries, the query fails. The default number of retries is retry=2. |
| Batch size | Splits the records in the result of a query in chunks of 10000 records by default and bulk uploads one chunk at a time. |

SELECT identifier_type, identifier
FROM table my_tableYou 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 Exporting Data with Parameters.
timezone: UTC
+td-result-output-sfdc:
td>: queries/sample.sql
database: sample_datasets
result_connection: your_connection_name
result_settings:
object: object_name
mode: append
concurrency_mode: parallel
retry: 2
split_records: 10000