Salesforce Commerce Cloud is one of the industry's most agile and scalable e-commerce platforms. Treasure Data offers a certified Salesforce Commerce Cloud cartridge that enables you to implement Treasure Data JavaScript SDK on your online storefront quickly. The cartridge automatically deploys TD JavaScript SDK tracking across the site, allowing you to collect various types of data, such as the following:

  • 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
    • URL
    • 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.

Privacy

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.
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:
    • Enabled
    • 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:

 <isinclude template=”treasuredata/tdSnippet” /> 


This Treasure Data template will download the TD JavaScript SDK snippet into your site to handle tracking actions. The download is asynchronous and does not impact your page loading.

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:

<isscript>
require('*/cartridge/scripts/tdTrack').trackPageview()
</isscript>

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:

<isif condition="${pdict.tdData}">
<isscript>
require('*/cartridge/scripts/tdTrack').trackEvent(pdict.tdData)
</isscript>
</isif>

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:

    1. role=button or role=link
    2. <a>
    3. <button>
    4. <input>, exclude for <input type='password'>

The Treasure Data cartridge automatically handles all communication required between your online storefront and the Treasure Data platform via asynchronous JavaScript. It only performs tracking functions and doesn’t impact viewable page content.





  • No labels