Insights

Setup Sitecore CDP And Validate

How To Simply Setup Sitecore CDP & Validate It

If you're new to CDP and Personalize and are going to be doing any form of development or marketing with it; I highly recommend taking the training and reviewing all the resources Dan mentioned in Sitecore CDP & Personalize Learning Resources.

Once you've had a nice review of that wealth of information, let's run through some quick and easy steps to get you up and running.

Setup

What you're looking to do is to update the main layout of your site with a <script> tag containing some JavaScript (which we will get into detail shortly). Depending on how your site is built there is any number of ways to do this. What I might recommend is having some form of configuration item or settings item that has a Rich Text field containing the Boxever JavaScript. This can then be loaded on the page. Makes for easy updates as needed.

The JavaScript

<script type="text/javascript">
    // Define the Boxever queue 
    var _boxeverq = _boxeverq || [];

    // Define the Boxever settings 
    var _boxever_settings = {
        client_key: '{{clientKey}}', // Replace with your client key
        target: '{{apiTargetEndpoint}}', // Replace with your API target endpoint specific to your data center region
        cookie_domain: '{{cookieDomain}}', // Replace with the top level cookie domain of the website that is being integrated e.g ".example.com" and not "www.example.com"
        javascriptLibraryVersion: '{{javascriptLibraryVersion}}', // Replace with the latest Boxever JavaScript library version"
        pointOfSale: '{{pointOfSale}}', // Replace with the same point of sale configured in system settings"
        web_flow_target: '{{web_flow_target}}', // Replace with path for the Amazon CloudFront CDN for Sitecore Personalize"
        web_flow_config: { async: false, defer: false } // Customize the async and defer script loading attributes
};
    // Import the Boxever library asynchronously 
    (function() {
         var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true;  
         s.src = 'https://d1mj578wat5n4o.cloudfront.net/boxever-{{clientVersion}}.min.js';
         var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x);
    })();
</script>

Let's break down what each parameter is and what you'll need to replace it with. Some are optional, but most are required.

Client Key - Required

You will get this within the CDP platform itself for the appropriate Organization located under Settings.

Locate Client Key under Settings to begin Sitecore CDP setup.

Target - Required

This is the API target endpoint. It's only one of three values, depending on your region.

  • https://api-us.boxever.com/v1.2 - North America
  • https://api.boxever.com/v1.2 - Europe
  • https://api-ap-southeast-2-production.boxever.com/v1.2 - Asia

Cookie Domain - Optional

This will be the root domain for your site. If you're operating on a sub-domain, e.g. us.abccompany.com, the cookie domain will be .abccompany.com.

It is key that you include the period at the start of the domain.

JavaScript Library Version - Optional

You can find a list of versions that you can determine the appropriate version. Likely the latest version.

Point Of Sale - Required

The Point of Sale, while just a string value, is a required value to enable experiments to display data, and events of guests are displayed in the timeline.

You can set it, if you don't have one already, under System Settings > Points of Sale as shown here.

This will be the same value you use in any Stream API integrations.

Locate Point of Sale under Settings for Sitecore CDP Setup

Web Flow Target - Optional

While this is an optional parameter, if you're using Sitecore Personalize then you'll want to add it.

For the majority of clients, the value will be https://d35vb5cccm4xzp.cloudfront.net

Web Flow Config

For most, this value can be left alone unless you've been directed to by Sitecore. They're also only required if you're using Sitecore Personalize.

Client Version

This will be the same JavaScript version you chose above.

Let's Validate Our Setup

It's fairly straight-forward to setup as you can see, but we need to validate it. What's the simplest way to do that? Well, for this example I've setup a simple site on Glitch. It was fast and easy and allows me to quickly validate my JS.

Next, we log into our CDP environment and go over to Experiences > Web as shown below.

Validate your Sitecore CDP environment through Experiences then Web.

Once there, in the top right corner click Create Experience give it a name. I chose, "Validation Test".

I'm then going to select a pre-made Alert Bar template.

Create a new Validation Test in Sitecore CDP

And with that, we've made something very, very simple.

Select Alert Bar template when validating in Sitecore CDP

After saving and closing, we're back at the main page of our Web Experience. While it's an optional step, it's important for this example to implement some Page Targeting.

Add Page Testing in Sitecore CDP Validation test.

Set it up with a URL to a page you can test with.

Enter URL in Page Targeting modal for Sitecore CDP validation test

We can then select Preview and enter the name of the page we selected as part of Page Targeting.

Preview draft version of validation testing in Sitecore CDP

But wait, it's not showing. What's wrong? Well, as part of the QA Tool we can see what's happening. When we entered our URL into Page Targeting we chose EQUALS and due to the preview containing query parameters, the URL isn't matching.

QA Tool for Sitecore CDP Setup Validation testing

Updating the Page Targeting to be CONTAINS we now see the banner properly showing up.

Validation of the test for Sitecore CDP setup is good.

Exiting the Preview, we can go back to our Experience and select Start and Publish. At that point, we can then track our experience in the Performance and Operational tabs of the Web Experience.

Sitecore CDP Experience has started

As our Experience has just started we won't have enough data. We also don't have a Goal set. So right now, it will be empty.

Sitecore CDP has started but no data yet and Goals are not set up.

In our Operational tab, however, we can see that indeed our Experience is working and we now know our setup is correct and working as it should.

See that Sitecore CDP is working under Operational tab

Our Setup Is Complete & Validated

Might seem like a lot of steps, but the more you do this the faster the process is. You also won't have to go through the process of setting up the code over and over for a single client; unless they have a lot of separate sites you need to track individually.

👋 Hey Sitecore Enthusiasts!

Sign up to our bi-weekly newsletter for a bite-sized curation of valuable insight from the Sitecore community.

What’s in it for you?

  • Stay up-to-date with the latest Sitecore news
  • New to Sitecore? Learn tips and tricks to help you navigate this powerful tool
  • Sitecore pro? Expand your skill set and discover troubleshooting tips
  • Browse open careers and opportunities
  • Get a chance to be featured in upcoming editions
  • Learn our secret handshake
  • And more!
Sitecore Snack a newsletter by Fishtank Consulting
 

Meet David Austin

Development Team Lead | Sitecore Technology MVP x 3

📷🕹️👪

David is a decorated Development Team Lead with Sitecore Technology MVP and Coveo MVP awards, as well as Sitecore CDP & Personalize Certified. He's worked in IT for 25 years; everything ranging from Developer to Business Analyst to Group Lead helping manage everything from Intranet and Internet sites to facility management and application support. David is a dedicated family man who loves to spend time with his girls. He's also an avid photographer and loves to explore new places.

Connect with David