Settings object
Use the settings object to initialize the Engage SDK. In the settings object, you include details about your Sitecore Personalize instance.
The Engage SDK supports setting cookies from the client and from the server.
-
To set cookies from the client, you must set the
forceServerCookieMode
attribute tofalse
and pass the settings object to theEngage.init()
function. -
To set cookies from the server, you must set the
forceServerCookieMode
attribute totrue
and pass the settings object to theEngage.init()
function on the client side, and to theEngage.initServer()
function on the server side.
The settings object includes the following attributes:
Attribute |
Type |
Description |
Example |
Required/optional |
---|---|---|---|---|
|
string |
Your client key. |
|
Required |
|
string |
Your Stream API target endpoint. The value depends on the location of your Sitecore Personalize server. |
Must be one of:
|
Required |
|
boolean |
Specify whether to add every UTM parameter from the URL of the current webpage to the event object. The default is If |
|
Optional |
|
string |
Your cookie domain. The default is what the browser sets. |
|
Optional |
|
integer |
The number of days before the cookie expires. If you don't specify this value, the cookie expires according to the |
For example, set the value to |
Optional |
|
string |
A URL path that must exist in the requested URL in order to send the cookie. |
|
Optional |
|
boolean |
Specify whether to set cookies from the client or from the server. If you can access the server side of your app, you can choose to set cookies from the server instead of the client. To set cookies from the server, set the value to The default is |
|
Optional |
|
boolean or object |
On the client side, specify whether you want to run personalization with Sitecore Personalize. This attribute is not available on the server side. If you don't specify this attribute on the client side, or if you specify it and set the value to If you set the value to If you set the value to You can customize the loading of the script by setting the value to an object. In the object:
The default is |
|
Optional on the client side. Not available on the server side. |
|
string |
The name of the point of sale where the interaction with your brand takes place. If you specified the You must set this value to the name of a point of sale that exists in your instance of Sitecore Personalize. If you don't specify |
|
Required if you specified the |
Initialize the Engage SDK, setting cookies from the client and using web personalization:
import { init } from "@sitecore/engage";
const engageSettings = {
clientKey: "<client_key_PLACEHOLDER>",
targetURL: "<stream_api_target_endpoint_PLACEHOLDER>",
pointOfSale: "<point_of_sale_PLACEHOLDER>",
cookieDomain: "<cookie_domain_PLACEHOLDER>",
cookieExpiryDays: 365,
forceServerCookieMode: false,
webPersonalization: false /* boolean or object. Default: false */
};
const loadEngage = async () => {
// Load Engage API
const engage = await init(engageSettings);
};