Sitecore Page Recommender: Trigger page level goals and events

page recommender

This blog post is part of a larger series that looks at the steps to create a
Page Recommendation Engine for Sitecore.


Introduction

In order to start predicting what type of course a user might want to view, we need to first of all start measuring what type of courses they actually like.

To do this we will create course page specific goals, each of which will be given an engagement value. These goals will be triggered as they navigate a course page and the sum of all this engagement will become their “Rating“ or measure of how much they “like“ the page.

You can see the page specific goals here: /sitecore/system/Marketing Control Panel/Goals

  • RegisterInterest(2F21C37C-7E88-4B3A-B30F-C29E050E1384)
  • Tab0 (38470D84-BA4E-4ABC-8740-9BCD66EF6E0F)
  • Tab1 (AB7FCA23-FB0F-45D3-AB3C-7C025D2CF01F)
  • Tab2 (0F049C02-0ED7-452C-905F-C15EF2B92680)
  • Tab3 (518C5ED4-B27A-4110-B1FB-C3646E9BF8A7)
  • Tab4 (F7DE34FA-251A-4ED7-B977-7010B634884A)
  • Tab5 (0E52F41D-771F-4A3D-B1FF-60DA7B87511E)
  • Tab6 (D1C9CEC3-50AE-4076-9434-B7AE9FDDDD16)

Triggering the Goal

In order to trigger the goals whilst navigating a course page, we need to register an endpoint within Sitecore to manage this and call it via Ajax.

Typically we would setup an endpoint like this to be an API endpoint, however if we did this then the Sitecore context and tracker would not be available.

Instead, we need to register a custom route:

RouteTable.Routes.MapRoute( 
  "yourcustomroute",
  "custom/path",
   new { 
    controller = "yourcontroller",
    action = "youraction" 
   }
);

where we register the route Trigger/Goal/{goalName}/{pageId} to call the RegisterGoalByNameAndPageId Action, within the standard SitecoreController.

Note: the main page layout has been adjusted to output the pageId as a javascript variable.

Example:

If you navigate to a page and click on the one a tab, this fires a ajax call to /Trigger/Goal/FeesFunding/" + pageId

Javascript

 $('[data-name="fees"]').click(function () {
    if (feesFunding) {
        $.post("/Trigger/Goal/FeesFunding/" + pageId + "/", function (data) { });
        feesFunding = false;
    }
});

This adds a goal to the current users interaction (in the Sitecore tracker), which is then submitted to XConnect when the users session ends.

Next up in the series: Collating, merging data and training our model

Leave a Reply

Your email address will not be published. Required fields are marked *