Sitecore Analytics Synchronisation (Sitecore 9.1 and later)

Sitecore xDB tracks some common analytics of which some can be synced to Salesforce and stored on the associated Contact/Lead. These values can be reported on and it includes - total goal score, goals reached, page visit count and profile data (profile name, profile keys and pattern cards).

Sitecore Configuration

The FuseIT agent can be registered in S4SMapping.config. Below is the code for it (it is commented out by default):

<scheduling>     <!-- S4S pushes Sitecore DMS data to Salesforce at the specified interval -->     <agent name="S4SUpdateAnalytics" type="FuseIT.S4S.WebToSalesforce.WebToEntity" method="BulkUpdateSitecoreAnalyticsInSalesforce" interval="00:30:00"/> </scheduling>
  • The interval setting needs to be in the right format of “HH:mm:ss”, say “12:00:00”, and should not be greater than “23:59:59”.

  • We believe Sitecore interprets interval="24:00:00" as 24 days

  • When using something like interval="00:30:00", the seconds and minutes cannot be greater than 60 so "00:70:00" will not work. Instead use interval="01:10:00”.

The FuseIT agent uses the Bulk API to update analytics in Salesforce. There are a number of configuration entries in the S4SAnalytics.config file that are used in this process which are configurable.

<!-- The number of Salesforce entities per batch to process analytics. --> <setting name="S4S.Analytics.BulkUpdateAnalyticsBatchSize" value="10000"/>   <!-- The number of records per batch to be sent to the Salesforce bulk API. --> <setting name="S4S.Analytics.BulkUpdateBatchSize" value="5000"/>   <!-- The number of seconds to wait for all batches in the job to complete and then get the results.      The bulk update will be cancelled if the specified time is exceeded although the bulk API jobs in      Salesforce will keep running.If set to 0 the bulk update will wait until all batches have finished. --> <setting name="S4S.Analytics.BulkUpdateResultsWaitTime" value="1800"/>
  • S4S.Analytics.BulkUpdateAnalyticsBatchSize This determines the number of Salesforce entities per batch to process analytics. For this batch size all the analytics are sent to the Bulk API to be pushed to Salesforce. The default value is 10000.

  • S4S.Analytics.BulkUpdateBatchSize This determines the maximum number of record in a Salesforce Bulk API batch. The maximum value is 10000. The default value is 5000.

  • S4S.Analytics.BulkUpdateResultsWaitTime This determines the amount of time, in seconds, the agent waits for the Salesforce Bulk API job to complete. If the wait time is exceeded the agent cancels the bulk update. The Salesforce Bulk API job will still continue to run until it is finished. The default value is 1800 seconds.

Each of the S4S Connection Strings then need to be configured in the /sitecore/system/Modules/S4S/Scheduled Tasks/BulkUpdateAnalytics item of the content tree:

The default S4SConnString is already configured, but set to disabled:

Note: The S4SUpdateAnalytics needs to first be enabled in the S4SMapping.config file for the bulk update to work.

The following fields can be set connection string item:

  1. Connection String Name: The name of the S4S connection string in the ConnectionStrings.config file.

  2. Is Enabled: Whether the connection string is enabled for bulk update.

  3. Last Run: This will display the last time that data was bulk updated to the Salesforce Organization that is specified in the S4S Connection String. It is automatically updated after a successful bulk update, but can also be manually set to a Date/Time as necessary (e.g. to update historical data). Note that the Run Time is stored as UTC.

  4. Run Time: When this field is set then the bulk update will be limited to run once per day the first time the S4SUpdateAnalytics agent runs at or after the time set here. If this field is not set, then the bulk update will run every time that the agent executes. For example:

    1. If Run Time is set at 14:00 [2.00pm] and the agent runs at 13.30 [1.30pm], then this there will be no bulk update performed.

    2. If Run Time is set at 14:00 [2.00pm] and the agent runs at 14:05 [2.05pm] and the ‘Last Run’ is not after 14:00 [2.00pm] (when converted from UTC) for the current day then the bulk update will run.

    3. If Run Time is set at 14:00 [2.00pm] and the agent runs at 14:05 [2.05pm] and the ‘Last Run’ is after 14:00 [2.00pm] (when converted from UTC) for the current day then the bulk update will not run since this means it has already run today.

    4. If Run Time is not set, then the bulk update will run.

  5. Is Running: This should not be set manually as it serves to prevent multiple bulk updates running for the same connection strings. It is set to true when the bulk update starts processing for the connection string and back to false when the bulk update finishes.

Adding Extra Connection Strings

If your Sitecore instance connects to multiple Salesforce Orgs and you need the Sitecore Analytics to bulk update to the separate orgs, then you will need to add extra Connection String Configurations to the BulkUpdateAnalytics folder for each connection string. The new Connection String Configuration item should be based off the /sitecore/templates/S4S/BulkUpdateAnalyticsConnectionString template. The Connection String Name and Is Enabled need to be set. Last Run and Run Time only need to be set if required.

Next Step

https://fuseit.atlassian.net/wiki/spaces/S4S/pages/1195540481

Steps