Upgrade from the Boxever JavaScript Library to the Engage SDK
If your organization started using Sitecore Personalize before March 2023, your app is probably integrated using the Boxever JavaScript Library. The Boxever JavaScript Library is no longer receiving updates, so we recommend that you upgrade to the Engage SDK instead.
This walkthrough assumes that you:
-
Have an app that uses the Boxever JavaScript Library.
-
Are familiar with HTML, JavaScript, and your web browser's developer tools.
This walkthrough describes how to:
-
Update the initializing script.
-
Update the VIEW event script.
-
Update the scripts for sending other events.
-
Update the script for running personalization.
Update the initializing script
To initialize the Engage SDK, replace your existing script for initializing the Boxever JavaScript Library with the new script.
Your existing script for initializing the Boxever JavaScript Library looks similar to:
Here's the new script for initializing the Engage SDK:
Replace the placeholder values with the required details from your Sitecore Personalize instance.
Note the following details about the Engage SDK script:
-
The
engage
variable is initialized asundefined
. -
After the
<script>
tag loads, the asynchronousinit()
function loads the Engage SDK on your webpages. Theengage
variable is reassigned to the return value of theinit()
function. -
The
settings
object has different attributes than_boxever_settings
in the Boxever JavaScript Library. For example,client_key
is nowclientKey
andtarget
is nowtargetURL
. -
To ensure that the Engage SDK script loads, you might have to add
https://d1mj578wat5n4o.cloudfront.net
and your Stream API target endpoint to your Content Security Policy (CSP). -
In production, only load the Engage SDK and set cookies if your site visitor grants consent. See also a code example to check if your site visitor accepts cookies.
Learn more about the Engage.init()
function and the settings object.
Update the VIEW event script
To send VIEW events, replace your existing script for sending VIEW events using the Boxever JavaScript Library with the new script using the Engage SDK.
Your existing script using the Boxever JavaScript Library:
Here's the new script for sending a VIEW event using the Engage SDK. Place this at to the bottom of the s.addEventListener()
function, below the engage = await window.Engage.init(settings);
line:
Replace the placeholder values with event data object values specific to your organization.
Note the following details about the Engage SDK script:
-
The event object has different attributes than in the Boxever JavaScript Library.
browser_id
andtype
are no longer part of the event object.pos
is nowpointOfSale
. -
The VIEW event has a dedicated function called
Engage.pageView()
.
Update the scripts for sending other events
In your existing Boxever JavaScript Library script, you're using the Boxever.eventCreate()
function to send any type of event. However, in the Engage SDK, some event types have their own function.
To send events, replace your existing Boxever.eventCreate()
functions with the applicable function from the following table:
Event type |
Function |
---|---|
VIEW | |
IDENTITY | |
|
Update the script for running personalization
In your existing Boxever JavaScript Library script, you're using the Boxever.callFlows()
function to run experiences and experiments.
To run personalization using the Engage SDK, use the Engage.personalize()
function.
Next steps
You've now successfully upgraded from the Boxever JavaScript Library to the Engage SDK. You initialized the Engage SDK, then updated your scripts for sending events.
Next, you can:
-
Learn more about sending behavioral and transactional data using the Engage SDK.