Getting the GuestRef in the Browser with Sitecore CDP/Personalize

Published:

A quick little post as I'm playing around with Sitecore CDP/Personalize. I've been playing around with the API's to get guest data. But I found that if I run this command in the developer console:

Boxever.getID()

This returned ID, is not the same thing as the Guest Ref, it's actually the Browser Id, and typically associated with the Cookie. You can use this ID inside your CDP/Personalize tenant and get the Guest Ref, but I've always found this a little confusing. It's funny how it all makes a little more sense now. When you search in the CDP/Personalize tenant with the Boxever Browser ID, it'll show a different ID in the Guest Profile, than you would expect to see. I just wrote this off and thought it could be a bug. But actually, this ID is the Guest Ref:

Boxever.getID() vs guestRef

Now that I finally know that these are two different things, what if I wanted to get the guestRef from the browser. There is a way, and I found this from Sarah O'Reilly:

Boxever.browserShow(Boxever.browser_id, Boxever.client_key, function(data) 
{ 
  console.log(data)
}, 'json');

Why do you need the guestRef? Well if you plan to do anything with the APIs, you'll need to know the guestRef in order to interact with them.