Deploy widget with CMS NuGet package
Use the Content Recommendations block type in Optimizely CMS to add widgets through the content editor interface.
If you 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 drop-down list to select the specific Delivery Configuration you want to use for this block.
- Recommendation Template – A field to enter the Mustache template that defines the HTML structure for each recommended item.
Template example
You can retrieve a default Mustache template from the Engage > Deliveries page 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 frontend and cannot access backend 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, manually deploy widgets or integrate through APIs.
Updated 8 days ago
