The CommerceTracker and CMS-only mode

Current version: 10.3

CMS-only mode occurs when you disable the xConnect tracker and xDB. Two common scenarios for this are:

  • when there is a period of peak sales (for example, during Black Friday), you can disable the xConnect tracker and xDB so that Sitecore processes requests at a faster pace.

  • when you have no need to collect data or perform analytics.

In CMS-only mode, no tracking occurs; hence, interactions are not recorded or persisted in xDB. Furthermore, no xDB contacts are maintained so new user registrations are not associated with an xDB contact or corresponding Personal and Emails facets and one result of this is that the user name and email address are not visible in the Experience Profile or in marketing automation campaigns. If or when xDB is re-enabled, and the user logs into the storefront, a new contact (with corresponding facets) is created for the user. User information is synchronized and information is available in xDB for use by other modules such as the Experience Profile and Marketing Automation.

In Commerce, the tracker enabled and disabled (CMS-only) modes are handled by an abstraction called the CommerceTracker.

Warning

To handle CMS-only mode, do not use xConnect Tracker directly in storefront and Commerce Connect customizations. Instead, use the CommerceTracker.

When the storefront uses CMS-only mode, the CommerceTracker orchestrates the activity of the providers ensuring the appropriate provider is loaded based on the current platform configuration. Two providers are used:

  • PlatformTrackerProvider is used when xDB is enabled and interacts with the Sitecore xConnect Tracker.  

  • CookieTrackerProvider implements tracking using a cookie (SC_COMMERCE_GLOBAL_COOKIE), which is saved and maintained by the browser.

CommerceTracker is a static class.

The CommerceTracker static class diagram

The following table shows the properties of the CommerceTracker class.

Property

Returns...

Current

The tracker based on the current system configuration that supports the ICommerceTracker interface.

IsXdbEnabled

True if xDB is enabled; otherwise, False.

The two default trackers implement the ICommerceTracker interface.

IcommerceTracker interface diagram, and PlatformTracker and CookieTrackerProvider class diagrams.

Properties and methods

ICommerceTracker supports the following properties and methods:

Properties

Returns...

ContactId

The ID of the current contact.  When in the Experience Editor, both versions return a static GUID to make sure the same user is always used. The PlatformTrackerProvider version supplies the contact ID.

With the CookieTrackerProvider version, for runtime site authenticated users, Sitecore.Context.UserName is returned. Anonymous users are assigned a new GUID in the cookie  SC_COMMERCE_GLOBAL_COOKIE.

ContactUserName

The PlatformTrackerProvider version returns the username as stored in the CommerceUser tracker source. The CookieTrackerProvider version returns the same value as ContactId.

EndVisit

Clears the tracker cookie and customer must re-enter credentials.

IdentifyAs(source, username)

The PlatformTrackerProvider version identifies the user with a source identifier of CommerceUser. The cookie version creates the cookie if it does not exist.

Extensibility

The type implementing the ICommerceTracker interface is instantiated dynamically based on the Connect configuration.  The Sitecore.Commerce.config file contains the following default entries that can be patched:

RequestResponse
  <platformCommerceTracker type="Sitecore.Commerce.Providers.PlatformTrackerProvider, Sitecore.Commerce.Connect.Core" singleInstance="true"/>
<cookieCommerceTracker type="Sitecore.Commerce.Providers.CookieTrackerProvider, Sitecore.Commerce.Connect.Core" singleInstance="true"/> 

By replacing the loaded types, you can change or extend functionality. You can provide your own types that implement the ICommerceTracker interface or extend an existing one.

Do you have some feedback for us?

If you have suggestions for improving this article,