Deploy widget via CMS NuGet package
Use the Content Recommendations block type in Optimizely CMS to add widgets through the content editor interface.
If you have installed the EPiServer.Personalization.Content.UI NuGet package for tracking, a Content Recommendations block type is available in your Optimizely CMS. You can add this block to any page where you want recommendations to display.
Block properties
- Number of recommendations – Defines the maximum number of recommended content items to display.
- Delivery Widget – A dropdown list to select the specific Delivery configuration you want to use for this block.
- Recommendation Template – A field to input the Mustache template that defines the HTML structure for each recommended item.
Template example
You can retrieve a default Mustache template from the Delivery page in the dashboard and customize it.
<div class="recommendations">
<h3>Recommended for you</h3>
<ul>
{{#content}}
<li>
<a href="{{link_url}}">
<img src="{{main_image_url}}?w=150&h=150" alt="{{title}}">
<h4>{{title}}</h4>
</a>
</li>
{{/content}}
</ul>
</div>
NoteThe recommendation template is rendered on the front-end and cannot access back-end Optimizely CMS APIs or content objects. It only has access to the JSON data returned from the recommendation server.
Limitations
When deploying a widget through the CMS NuGet package, you cannot use script attributes like data-filter to dynamically filter recommendations on the client-side. For more advanced implementations, a manual deployment or direct API integration is recommended.
Updated 18 days ago