Blog posts by Magnus Kjellander2019-01-08T12:54:19.0000000Z/blogs/magnus-kjellander/Optimizely WorldEpiserver Advance content recommendations block/blogs/magnus-kjellander/dates/2019/1/episerver-advance-content-recommendations-block/2019-01-08T12:54:19.0000000Z<p>As you probably have heard we launched Episerver Advance earlier this year. Advance is the latest addition to our personalization suite and is a service for content personalization and enables you to recommend content to your visitors at any given time that vary based on their experience and needs.</p>
<h3>How it works</h3>
<p>The process can be described with the following steps:</p>
<ol>
<li>Track – every interaction with your site is tracked back to Episerver Advance.</li>
<li>Create – your editors create content, preferably lots of it and diverse.</li>
<li>Analyze – the machine learning algorithms analyze tracking behavior and content.</li>
<li>Visualize – the service sends recommendations back to the user based on the analysis.</li>
</ol>
<h3>Getting started</h3>
<p>As an example and help you get stared with Episerver Advance we have created a block available on Github, <span><a href="https://github.com/episerver/ContentRecommendationBlock">https://github.com/episerver/ContentRecommendationBlock</a>. </span><span>The block shows a number of recommended pages set by the editor to the visitor. No styling has been added to the block but what that’s not a priority here. </span></p>
<p>I have set the content recommendations block up on a clean Alloy site. The first thing that needs to be done is getting an Advance account. When ordering Advance, you will get configs for both tracking and getting recommendations that need to add to your web.config.</p>
<p>The next step is to install nuget-packages. The packages needed are EPiServer.Tracking.PageView and Episerver.Personalization.CMS. EPiServer.Tracking.PageView is for tracking and Episerver.Personalization.CMS is the one used for getting the recommendations. The packages need the configs for your Advance account and can now be set.</p>
<p>EPiServer.Tracking.PageView:</p>
<pre class="language-markup"><code><add key="episerver:profiles.TrackingApiBaseUrl" value="ChangeThis" />
<add key="episerver:profiles.TrackingApiSubscriptionKey" value="ChangeThis" />
<add key="episerver:profiles.ProfileStoreTrackingEnabled" value="false" />
</code></pre>
<p>Episerver.Personalization.CMS:</p>
<pre class="language-markup"><code><add key="episerver:RecommendationServiceKey" value="ChangeThis" />
<add key="episerver:RecommendationServiceSecret" value="ChangeThis" />
<add key="episerver:RecommendationServiceUri" value="ChangeThis" />
</code></pre>
<p>The tracking needed for Advance is, as you might have figured from the name of the package, pageviews. Using the package, we add [PageViewTracking] to the page controller methods we want to track, as below. Add tracking to all as many of your pages as possible, the more the better.</p>
<pre class="language-csharp"><code>public class DefaultPageController : PageControllerBase<SitePageData>
{
[PageViewTracking]
public ViewResult Index(SitePageData currentPage)
{
...
}
</code></pre>
<p>Next, I just added the project to my alloy site. The content recommendation block is using an API-call to get the recommendations, so I needed to add the following to the route config:</p>
<pre class="language-csharp"><code>System.Web.Http.GlobalConfiguration.Configure(config =>
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(name: “DefaultApi”, routeTemplate: “api/{controller}/{action}”, defaults: new { id = RouteParameter.Optional });
});
</code></pre>
<p>That’s it! When creating the block on the site there is only one property available for the editor.</p>
<p><img src="/link/6bbfef06f7a44ec2903738a25e8fbf27.aspx" /></p>
<p>And then on the site the block containing the links.</p>
<p><img src="/link/ac6a56b544a24cd1ae3b59c121309137.aspx" /></p>