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 importing 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:
Ranking: What are the “Top N of X?”
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.
Continue to the following topics:
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:
Use the TD Console to Create Your Connection
Create a New Connection
Connecting to Salesforce using the TD Console is quick and easy. Alternatively, create a Salesforce connection using the command line. The import integration supports credentials; you need a client ID and client secret to authenticate using credentials.
Allow TD to Access Salesforce using Salesforce
These instructions guide you to locate the client ID and client secret that is necessary to authenticate using credentials. Go to Setup > Apps > App Manage. Select New Connected App. Navigate to Setup > Build > Create (Apps), and validate all your connected apps: Select your app name to go to the page where you can view and manage all information about your connected app. Write down or copy your Consumer Key (client_id) and Consumer Secret (client_secret). 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.
The steps may vary depending on the version of Salesforce you are running. In Spring 19 classic UI: Setup > Build > Create > Apps > Connected Apps > New.
In Spring 19 classic UI: My account > My Settings > Personal > Reset My Security Token.
These instructions guide you to locate the client ID and client secret that is necessary to authenticate using credentials.
Go to Setup > Apps > App Manage.
Select New Connected App.
Navigate to Setup > Build > Create (Apps), and validate all your connected apps:
Select your app name to go to the page where you can view and manage all information about your connected app.
Write down or copy your Consumer Key (client_id) and Consumer Secret (client_secret).
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.
Create New Connection in TD Console
Open TD Console.
Navigate to Integrations Hub > Catalog.
Search for Salesforce.
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.
5. Select Continue.
6. Give your connection a descriptive name and select Create Connection.
Validate Your Salesforce Connection
To validate the user permission, make sure to use Salesforce to validate:
Authority: check the Salesforce import 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:
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.
- Complete the instructions in Creating a Destination Integration.
Navigate to Data Workbench > Queries.
Select a query for which you would like to export data.
Run the query to validate the result set.
Select Export Results.
- Select an existing integration authentication.
- Define any additional Export Results details. In your export integration content review the integration parameters.
For example, your Export Results screen might be different, or you might not have additional details to fill out:
Run your query.
Validate that your data moved to the destination you specified.
Integration Parameters for Salesforce
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
|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
|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.|
Optionally Schedule the Query Export Jobs
You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify.
1. Navigate to Data Workbench > Queries.
2. Create a new query or select an existing query.
3. Next to Schedule, select None.
4. In the drop-down, select one of the following schedule options.
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.|
Custom cron... Details
Run once an hour
Run once a day at midnight
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.
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.
|configures the schedule to run at midnight (00:00) on the first day of each month.|
|a range ||configures the schedule to run at midnight (00:00) on the first 10 days of each month.|
|a list of comma-separated values ||configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month.|
|a periodicity indicator ||configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. |
|a comma-separated list of any of the above except the ||configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month.|
5. (Optional) If you enabled the Delay execution, you can delay the start time of a query.
Execute the Query
Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically imported to the specified container destination.
Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications.
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.