Use FreeMarker snippets in an API request for a triggered experience
Sitecore Personalize provides you with FreeMarker snippets that you can copy and paste into the API request. For example, if you selected a decision model to return offers or content, you must include the offers or content in the API request using FreeMarker.
To copy and paste FreeMarker snippets in the API request:
-
In the API editor, click the API body tab.
-
On the Snippets tab, browse the available FreeMarker snippets that you can copy and paste into the API body tab.
-
Click the Copy link next to the code snippet that you want to copy.
-
Paste the code snippet into the API body tab.
-
Click Save.
-
Click
to close the API editor.
Check if variable exists
You can use this FreeMarker snippet to check if a variable exists. This helps eliminate errors if there's a null or missing value.
Convert epoch dates and times
Sitecore Personalize manages dates and times in epoch. You can use this FreeMarker snippet to convert dates and times in epoch to a format that FreeMarker can interpret.
Extract sessions or orders
You can use this FreeMarker snippet to extract sessions from the guest object to a list format that FreeMarker can interpret. You can also use a similar snippet to extract parameters from the orders object.
Verify number counts
You can use this FreeMarker snippet to verify number counts.