Headless Example
This article shows how to personalize content using the Umbraco Engage Headless API and Umbraco’s Content Delivery API.
Last updated
This article shows how to personalize content using the Umbraco Engage Headless API and Umbraco’s Content Delivery API.
Last updated
This article shows how to use the Umbraco Engage Headless API with Umbraco Content Delivery API.
Go to the Engage > Personalization section.
Navigate to the Segments tab.
Click Add new Segment.
Give the segment a name. For example: Morning People.
And a description such as For people who like to visit us in the morning.
Set the segment type to Core as this is not temporary and is tied to an end date for a campaign.
Select the Time of day parameter and configure it to Include times from 00:00 to 12:00 as it is a 24-hour clock.
For more information, see the Personalization documentation.
Navigate to Settings.
Click Create a New Document Type.
Enable Allow Segmentation under Permissions.
Save the Document Type.
Add a new property, such as a Header, using a Textstring property editor.
Ensure Allow Segmentation is enabled for this property.
Create a piece of content using this new Document Type to query and request it using the Umbraco Content Delivery API
For this example, create this piece of content at the root.
Open the created content and go to Personalization.
Click Add personalized variant.
Set the following in the Add a new variant dialog:
Choose the segment Morning People we added earlier.
Give it a name and a meaningful description such as Home Page for Morning People.
After adding the variant we will return to the content node in split-view mode.
We can then add a different piece of content we want to return in our Header property specific to morning people such as Hello you early risers.
Save and publish the node with the variant content.
Let us use the Swagger development tool to make requests to the Umbraco Content Delivery API and Umbraco Engage Headless API.
Navigate to the swagger endpoint of your site /umbraco/swagger.
Select Umbraco Delivery API from the dropdown.
Expand /umbraco/delivery/api/v1/content/item/{path}
:
Click Try it out.
For the path parameter, enter /
for the example piece of content we created at the root of our site - alternatively, specify the correct URL path to the content.
Set the API-Key parameter if your Umbraco application requires Public Access this can be toggled with the configuration value Umbraco:CMS:DeliveryAPI:PublicAccess
You should view the JSON result of the content node, including the default header value.
Navigate to Umbraco Engage Marketing API from the definitions dropdown.
Expand /umbraco/engage/api/v1/analytics/pageview/trackpageview/client
:
Click Try it out.
Modify the JSON body, setting the URL to the page visited earlier. With the content delivery API above, leave the other property referrerUrl empty.
Repeat the earlier steps to fetch the content by its path. The JSON of the content node and the header property now contains our personalized content Hello you early risers
Remember it will only show different content if we view the page before midday.
Umbraco Engage is licensed to individual domains. It requires the Host Header to match one of the registered licensed domains for personalization and A/B Testing to work.