Activating Sitecore CDP – A Developer’s Guide

Editor’s note: This blog post is the second in a series focused on a developer’s quick guide to Sitecore CDP.

Now that you’ve learned what Sitecore’s CDP is all about, it’s time to activate it in your website’s backend. This post will take you through how to activate the CDP itself as well as how to add custom data to your backend. You’ll also gain a sneak peek into what Sitecore CDP looks like once it’s correctly implemented.

CDP Activation

When a user visits the website, the CDP JavaScript library creates a cookie and assigns it a browser ID. From then on, every event and action the user is making will be registered under this specific browser ID.

To initiate this, developers first need to include the JavaScript library within the backend of your website by copying and pasting the following code. Then, they can close the tag in the website template page.

Code for CDP Activation

Pushing Events into the Queue 

After the CDP is activated, guest events will need to be registered. It happens by sending the “events” into the event queue. Common guest events include page views, searches, payments, checkouts, etc.

Sending raw event data is easy using the following JavaScript example for a page view event:

Code for pushing events into the queue

Here’s another example of sending raw event data – this time for adding a product to a shopping cart: 

code for sending raw event data

You can send tracking data to Sitecore CDP by adding the following line before the “eventCreate” function:

code to add before the eventCreate function

Adding Custom Data to the Data Model

The data is being saved in Sitecore CDP Data Model, a flexible and extensible solution that enables developers to add custom data as extensions to fix business differences as key value pair.

Sending Custom Events

Sitecore CDP has a good list of standard events, however, sometimes the business need may require you to use a custom event. Custom events are sent the same way as a standard event. In order you send a custom event, though, you will need to follow the same naming standards. For example, having the name of the event in all uppercase letters.

CDP reserved event list name:

custom events chart

Note: If you need to end the session before the timeout, to push and process the CDP data, you have to send the event as FORCE_CLOSE. This will come in handy during the development phase, but not during production.

Identifying Guests and Sending Guest Data

Once a user is logged in, and the “Identity” event has been triggered, the CDP will scan for any existing profiles that match the exact identity. If the identity is not found, it will create a brand-new profile.

It’s worth noting that sending an “Identity” event will not push the guest’s information (first name, last name, email address). So, to create the guest profile with the required data in the CDP, you need to call the POST API: /v2/guests and pass the guest data model as JSON.

The following guest data model is an example of how to create a guest using those identifiers:

guest data code

It’s also important to note that “create guest” does not check if the guest exists before its created. So, to avoid duplication, use the locate guests first function in Sitecore CDP REST API.

Sitecore CDP has a long list of available guest model attributes. Check the list on the Sitecore CDP guest data model for REST API.

If the aforementioned list does not contain enough for your business needs, you can add custom guest data using the following data extension:

custom guest data code

Consult the following guidelines when using the guest data extension:

  • A guest type can only have one data extension.
  • The name of the guest data extension must be ext.
  • The key of the guest data extension must be default.
  • The attribute name of the guest data extension must be alphanumeric [A-Z,a-z,0-9] as per the json rfc7159 specification.
  • The attribute name of the guest data extension must be written in camelCase.
  • The attribute name of the guest data extension must be unique within the entire guest type.
  • Make the attribute name meaningful.
  • If grouping is required, use common prefixes.
  • A guest data extension has a maximum of 100 attributes.

The Results

Parts one and two of this series have led us through the set up of the Sitecore CDP. We’ve pushed various events including “Page Views” and “Identity” and we’ve updated customer profile data. Now, let’s go through how to view the aggregated information and the value it can offer to marketers. 

Guests Data

guests data dashboard

In the Sitecore CDP dashboard, marketers can access “Guests” from the panel located under the Customer Data panel. They can then view live data for all guests including those that are anonymous (the ones that haven’t been identified yet). Clicking on a visitor will open that specific visitor’s profile page which then displays detailed information about each visit, the channel used to visit the site, first and last time visited, total amount spent, and much more. 

dashboard with live data

Marketers can also check the interaction timeline for each visitor. They can filter by “Interactions Type” and “Date” as well as by “Order Details” and “Guest Information.”

interaction timeline



guest information



This article provided a brief summary on Sitecore CDP. It’s meant to be used as a quick guide to help developers jump start their CDP integration. If you’re not sure where to begin on your integration, let help you. Our dedicated team of Sitecore experts can guide you through the process – no matter which solution you’re looking to implement. is a Sitecore Platinum Implementation and Hosting Partner with platform expertise spanning over 10 years. For mid to large enterprise clients looking for a flexible, powerful content management solution, creates user-focused, digital experiences by integrating strategy, UX, and design that delivers transformative results. Contact us today to learn how is the perfect Sitecore partner.

Stayed tuned for another two-part series focused on the features of the Sitecore CDP such as experiences and experiments. The series will close out with a practical personalization example using Sitecore CDP. 

About Author

Naim Al
Naim holds a Bachelor Degree in Information Technology and an MBA in Finance. He started his career in programming in 2001 building desktop financial applications. In 2004 he shifted his focus to develop websites. In 2016 Naim joined as a Senior Sitecore Developer. In 2020 Naim won the 1st place in Sitecore Hackathon 2020 competition with American Eagle XTeam Winner, over 82 teams from more than 23 countries were participating. When he is not coding, he likes to spend time with his wife and two kids, watching TV, or relax in his backyard.

Featured Posts