Test a condition
Sitecore CDP enables you to test a condition by running it against a selected guest.
We recommend testing the condition before you publish it, to identify any errors and ensure optimal performance. After changing the code, re-test the condition with the same guest to check the results.
For more advanced use cases that require passing in headers and parameters in the request, you can test an advanced condition.
When you test a condition, Sitecore CDP tests the JavaScript on the server-side. This ensures that the JavaScript is validated within the context it will be executed in.
Team members with a User, Developer, or Admin role in Sitecore Cloud Portal can test a condition.
To test a condition:
-
Open the condition and click Test.
-
In the Test Condition dialog, you can test against the default guest's attributes, or click in the search box and choose Recent to select from a list of recently active guests or Bookmarks to select from a list of bookmarked guests. To select a specific guest, enter their unique identifier into the search box. You can search for a guest using, for example, an email address, other unique identifier, or browser ID.
NoteIf there is a guest whose data you often use when configuring or testing code, just click the star icon to bookmark the guest so you no longer have to search for them.
-
To temporarily modify the guest data (this is only temporary and does not change any attributes associated with the guest), edit the JSON in the code editor.
-
To configure the guest parameters and view them in the response of the test, you must include this JavaScript in the code editor to call the
guestcontext:RequestResponse(function () { return { guest: guest }; })(); -
Click the Condition parameters option to enter values and click Test. The guest parameters is included in the response.
-
To include the Point of Sale parameter and view it in the response of the test, you must include this JavaScript in the code editor to call the
requestcontext.RequestResponse(function () { return { request: request }; })(); -
Click the Experience request option and select the point of sale and click Test. The
pointOfSaleparameter is included in the response. -
To include the
tenantparameters and view them in the response of the test, you must include this JavaScript in the code editor to call thetenantcontext, as shown here:RequestResponse(function () { return { tenant: tenant }; })(); -
Click the Condition parameters option to enter values and click Test. The tenant parameters are included in the response.