Skip to main content
Users
CloudPortalLogin
  • Powered byPowered by
Introduction to Sitecore Personalize
Managing accounts and system settings
Identifying guests
Introduction to experiments
Introduction to experiences
Decisioning
View dashboards
Developer Center
Connecting to an external system
Using client-side JavaScript
Using server-side JavaScript
AI in Personalize
Glossary
  • Sitecore Personalize
  • Introduction to experiments in Sitecore Personalize
  • Introduction to interactive experiments in Sitecore Personalize
  • Compose the API response for an interactive experiment
  • Use FreeMarker snippets in an API request for an interactive experiment

Use FreeMarker snippets in an API request for an interactive experiment

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:

  1. In the API editor, from the API tab, click the Snippets tab.

  2. Browse the available FreeMarker snippets that you can copy and paste into the API tab.

    Copying FreeMarker snippets into the API request
  3. Click the Copy link next to the code snippet that you want to copy.

  4. Paste the code snippet into the API tab.

  5. Click Save.

  6. 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.

RequestResponse
<#if guest.orders[0]??>
	<#-- get last order -->
</#if>

Verify number counts

You can use this FreeMarker snippet to verify number counts.

RequestResponse
<#if children?number &gt; 0>
    <#if infants?number &gt; 0>
        <#if children?number &lt; 1 || infants?number &lt; 1>
	        <#assign family = "false">
        </#if> 
    </#if>
</#if>

Do you have some feedback for us?

If you have suggestions for improving this article,

Privacy policySitecore Trust CenterCopyright © 1999-2026 Sitecore