Sitecore CDP offers a robust mechanism for capturing and organizing user data from your website. To effectively gather data, CDP relies on events as the primary means of transmitting information. Behind the scenes, CDP operates as an extensive database, storing individual user sessions and all the events associated with each session. This repository of user-specific data becomes a valuable resource, providing comprehensive insights into user behavior and preferences.
Events play a crucial role in CDP's data collection process. They act as data markers, capturing important interactions and actions performed by users on your site. CDP allows you to view these events categorized by session, presenting a user-friendly interface that simplifies data analysis for both technical and non-technical users. This transparency enables anyone to gain a clear understanding of user activities on your site.
By default, CDP includes essential events that are applicable to most websites, such as pageviews, identity events, add to cart, and checkout events. These pre-defined events offer valuable information about user engagement and conversion activities. However, CDP understands that every website is unique, and there may be specific events that are relevant to your business and require tracking. To accommodate this need, CDP allows you to define and send custom events tailored to your specific requirements. Custom events provide granular insights into user interactions, allowing you to understand and personalize user experiences in more detail.
Moreover, CDP offers the flexibility to include additional data with default and custom events. For example, when a pageview event occurs, you can supplement it with supplementary information about the specific page the user is viewing. This added context enriches the data, providing a more comprehensive understanding of user actions within the given context.
In order to send events, you need to have your site connected to your CDP account using the Sitecore Engage library. You can see how to connect your site here: CDP Introduction. This library does a lot of things for you, so sending events is really easy! To see the official documentation go here: Sitecore CDP developer documentation.
Each event is an object that is sent to CDP. There you have some required attributes and some optional ones. This applies to all the events that are sent to CDP (default or custom ones).
Attribute
Description
Example
Required
channel
The touchpoint where the user interacts with your brand.
The alphabetic currency code of the currency the user is using in your app.
EUR, GBP, USD
REQUIRED
pointOfSale
The name of the point of sale you specified in CDP.
mypointofsale.com
REQUIRED
language
The language the user is using your app in.
DE, EN, FR
OPTIONAL
page
The name of the webpage where the interaction with your brand takes place.
home, contact-us.html
OPTIONAL
If you need to send additional information, you can create extension data object and there you can add a maximum of 50 attributes for any event. It is an optional parameter of the event function.
Finally, to send the event you just need to add this line of code:await engage.event(eventType, eventData[, extensionData]);You can send all the events that way, but CDP has created specific functions for the page view event and for the identity event.
For this event, in addition to all the needed attributes, you need to send the identifiers attribute, which is an array of objects where you define the provider and the id. The provider is the name of your organization’s identity system. You can see it in your CDP account by going to settings and clicking on the Identity rules.
In this case, the provider needs to be ‘email’.
Also, you can optionally send a lot more information (PII) in the identity event as string attributes: email, title, firstName, lastName, gender, dob, mobile, phone, street, city, state, country, postalCode.
To send this event just add this code:
The only needed attribute for this event is the product one. It is an array of objects with the item ids of all the products added to the cart that want to be confirmed for checkout.
If you send an item id that wasn’t send in an ADD event before, it will cause an error. Also, it is important to mention that if you added to the cart 10 products, but you only send 2 item ids in the confirm event, CDP will only track that the user bought those 2 products.
Here is an example after sending the last ADD event:
This is a special event that can be sent in order to close a session of a user instantly. This event is usually used to test what happens when the user closes a session (it is not recommended to use it for a production environment).
Here is the snippet of code used to send this event:
For any custom event, you need to send the required attributes for all events, and additionally, you can send anything else you want.
Here is an example:
If you have sent all the events until this point in order, go to CDP and search your guest. There you should be able to see 2 sessions. The first session is going to have all the events sent before the FORCE_CLOSE event (VIEW, IDENTITY, ADD, CONFIRM, CHECKOUT). Because there is a checkout event in this session, the session is going to be a converted session and you will see the value of it.
If you click on View Session Details, you will see all the events sent to that session.
You won’t be able to see the FORCE_CLOSE event because it is not used in real scenarios.
The second session should only have the custom event.