Walkthrough: Tracking user interactions
This walkthrough is the part four of the Developing the UI walkthrough series.
At runtime without requiring any additional code, Sitecore Discover JS SDK registers user interactions. The JS SDK is either directly or indirectly involved with these interactions. However, there are some events that the JS SDK has no awareness when they take place.
To track events that do not involve the JS SDK, you need to track them verbosely.
When a visitor logs in or adds an item to the shopping cart, there is no way for the JS SDK to know these events without being specifically informed. All funnel and some global events have to be verbosely tracked as shown in the following procedure to log in a user.
To dispatch an event verbosely to log in a user:
import { trackUserLoginEvent } from '@sitecore-discover/ui';
trackUserLoginEvent({
id: '8743b52063cd84097a65d1633f5c74f5',
email: '[email protected]',
// Optional. User's billing address
address: {
address_line_1: '123 Main Street',
address_line_2: 'apartment 123',
state: 'CA',
zip: '90210',
country: 'USA',
},
// Optional
gender: 'female',
groups: ['group1', 'group2'],
addn_attributes: {
email_subscriber: 'True',
preferred_sizes: ['S', 'M', '32W', '30L'],
home_store_code: '4321',
}
});