Closing a Session in Sitecore CDP with the Stream API Using Postman

Published:

As the excerpt described, I have been working on a video for the Discover Sitecore YouTube channel related to Sitecore CDP/Personalize with the use of Real-time, also referred to as the Stream APIs typically used by the Sitecore CDP JavaScript library to track events in the browser. Technically by using the API’s I am in essence mimicking the behavior you might trigger if another system wanted to track behavior such as a Mobile application or maybe even a third-party system.

As was the case with Sitecore XP, it was always great if you could kill the .NET session, especially when you wanted to test the output of something you might be demonstrating to a customer in real-time or content for a video/blog. Unlike in the days of the .NET development and the .NET application with XP, where you might need to build a custom admin page that you could call while logged in to kill the session, in the realm of Sitecore CDP, you have a way to do this at any point, as long as you have a Browser Ref. In a previous blog topic on my blog about Getting the Guest Ref from the Browser Ref, I talked a little more about these different references. So you could theoretically kill the session at any point for the user by writing some JavaScript, but I’ll cover today how to do this using an API request using Postman. You might be in the middle of a demonstration like I was when creating the YouTube content, and need to show the browsed session versus the open session in Sitecore CDP (keeping in mind that CDP is the only way to view your guest data).

I’m going to show this in postman, but anything could work here to make these requests including CURL.

You can view the postman request script here if you would like to import this into Postman: Gist Postman Script.

Or you can just refer to the screenshots below. You’ll need to create an environment for your specific Tenant of CDP/Personalize and then you’ll need values for the following:

  • API Endpoint - This is for your region such as api-us if you are accessing a tenant in the US
  • ClientKey - This is the public key for accessing your tenant.
  • Message - This should be left blank and filled with your pre-request script details
  • POS - This is the point of sale that you specified earlier when you set up your tenant and start ingesting data.
  • Browser ID - This is a variable that you should’ve defined previously. Such as when you created the session you would want to store this Browser Ref for future requests, however, if you just want to use an arbitrary value, that can be done as well.

Includes Request Details to Close or Kill the Session in Postman for Sitecore CDP/Personalize

Includes details for the creation of the {{message}} variable for the request in Sitecore CDP/Personalize.

General

Home
About

Stay up to date


© 2024 All rights reserved.