- Page impressions: Discover which pages a user is visiting.
- Events tracking: Identify an action performed by a user, including product purchases and other information about the user's activities.
- Click tracking: Track which objects a user selects, such as a link, a button, or an input element.
The Treasure Data cartridge doesn’t store any data within Commerce Cloud. All data tracked and collected by the cartridge is stored within Treasure Data's secure platform. After collecting this data, you can easily integrate your Commerce Cloud data with your customer data in Treasure Data, providing additional insights from eCommerce purchases and behaviors.
Prerequisites and Limitations
- Treasure Data account
- Salesforce Commerce Cloud account
- Salesforce Commerce Cloud (SFRA) version 6.0.0. Compatibility mode: 21.10
- Salesforce Commerce Cloud console tracking capabilities enabled via preferences require:
- TD API write key
- Database and table names where data is to be stored
- The availability of the cartridge itself is expected to be 100%. The availability of the tracking functionality is dependent on the availability of Treasure Data API services.
- If the cartridge is down there will be no interruption of your workflow and you can disable the cartridge via a custom preference as needed.
The Treasure Data cartridge does not automatically collect or process user profile information and Storefront site information. No credit card data is parsed or collected.
Setting Up the Commerce Cloud cartridge
1. Download the TD cartridge from AppExchange.
2. Upload the int_treasuredata cartridge to your server or sandbox.
3. Register the cartridge: navigate to Business Manager: Administration > Sites > Manage Sites > [select site].
4. Select the Settings tab.
5. In the Cartridges field, add int_treasuredata to the end of the list, separated by a colon.
6. Select Apply.
7. The next step is to import Custom Site Preferences into Business Manager. To prepare, zip the metadata folder under the link_treasuredata root folder or you can use the metadata.zip available in the root folder.
8. Log in to the Business Manager
9. Navigate to Administration > Site Development > Site Import & Export.
10. Select Choose File and browse for the metadata.zip from step 1.
11. Select Upload.
12. Select the metadata.zip file
13. Select Import
14. Confirm the import.
Configuring the Cartridge
You need to set several custom site preferences in the Treasure Data preferences group. For more information about the configurations, visit our JS SDK documentation.
To set preferences:
1. Navigate to Merchant Tools > Site Preferences > Custom Preferences.
2. Select TreasureData preferences group to see details of each preference.
3. Edit the site preferences. The following site preferences must be set for the cartridge to work:
- Write-only key
- Database name
Other site preferences are optional. Depending on the requirements, preference options can be switched on or off. For more information about the configurations, please visit our JS SDK documentation.
4. Select Save.
Setting Up Tracking
Update the template
Navigate to templates/default/common/layout/page.isml. To update the template, add the following line under the <head> tag:
Add Pageview Tracking
After the template is updated, you can add a script to add page view tracking to your site. Add an isscript tag to call our tracking pageview function as follow:
Add Event Tracking
You can also add event tracking which will track custom data such as product names and IDs of specific products that a customer views. This requires some custom code in the controllers and a call to the tdTrack.js function.
You can call the tdTrack.js function from your template file to track custom data using the following code:
The tdData property name in the pdict is not mandatory. You can give it any name in your controller. Also, make sure that the property is set before calling the tracking function to avoid unexpected errors.
You can see how to use custom code in the following product controller example:
The isscripts for page views and event tracking can be added to any page based on the requirements, but you can make it work for all of the pages on your site by adding it to templates/default/common/layout/page.isml under the <head> tag and requiring that it is added after the Treasure Data template.
Add Click Tracking
You can enable this feature by setting the Enable Click Tracking? preference to Yes. After click tracking is enabled, the Treasure Data script tracks click actions on the following elements:
- role=button or role=link
- <input>, exclude for <input type='password'>