Blog / Content Management

Personalization in Kentico Cloud – Part 2


by Martin Michalik

Apr 11, 2018

Personalization is about delivering the right information to the right people at the right time. You won’t succeed with personalization if you don’t know who your visitors are and what they’re looking for. Therefore, tracking your website visitors is essential for your success. But is it enough?

In my previous blog post, we talked about the ever-growing volume of content produced, and learned what it means for marketers, why companies will have to distinguish themselves and how personalization can help with that. Today, I would like to continue and show you the foundations of personalization—tracking the behavior of your visitors.

The Web Is Dead, Long Live the Omnichannel 

It’s probably not news to you that mobile Internet usage has surpassed desktop browsing (actually, it had already happened by October 2016), but did you know that Apple is today the biggest watchmaker in the world? And would you expect three years ago that your customers might be consuming content on their watches?  

The days where the web was the only and primary channel are over. With new channels and devices emerging every day, you will not only need to deliver content to all those devices, but you will also need to track and personalize the content there.  


This gets us to the concepts of headless CMS and adaptive content—if you structure your content well and use a technology agnostic CMS, you’re able to deliver the content to basically any channel or device. But what about its personalization? 

The majority of headless CMSs do not provide you with out-of-the-box personalization capabilities, they let you integrate with a third-party service or your custom implementation. This is not necessarily a wrong approach as it provides you with flexibility in today’s world of micro-services, but it also means that marketers will need to learn how to use another tool that might be too disconnected from the content. 

However, there’s another option—Kentico Cloud provides you with the capabilities to deliver content to multiple channels together with out-of-the box tracking and a personalization API. Let’s see how it works! 

Where to Start? 

Kentico Cloud supports two types of tracking of your visitors—you can either track your visitors automatically using the out-of-the-box web tracker or you can set you own custom events and log those manually as they occur. 

To enable visitor tracking, your developers need to deploy the tracking code into the code of your website. You can find the code in the Tracking application on the Tracking code tab. Simply copy and paste the Javascript code into the header code of every page on your website you want to track. Alternatively, you can inject the tracking code via Google Tag Manager. 


Once the tracking code is deployed, your visitors will be tracked automatically. The tracker will automatically collect information such as what website the visitor came from, the location of the visitor based on their IP address, or the journey of the visitor through your site (which pages they visited, how many times, etc.). 

Moreover, Kentico Cloud automatically tracks form submits on your website and every anonymous visitor becomes a contact when they enter their email into any form on any tracked page. The form data is then combined with the information you have previously collected about them to create a contact profile. 

Manual Tracking

While having your customer behavior tracked automatically is great, sometimes you might want to define your own custom events, track and then use them for the personalization of your content. A nice example of such an event is a click on a specific call-to-action banner, similar to the one you can see in the picture below.  


Now, let’s see how you can define and track custom events (we call them Custom Activities) in Kentico Cloud. It’s a simple two-step process—we need to define our custom activity and then log it using the Kentico Cloud tracker. 

You can define new Custom activities in the Tracking application on the Activity tracking tab by specifying the name of the custom activity. Once you specify the name, a codename is automatically generated for you from the activity name and you can use it later for logging the activity. 


Logging the custom activity is simple: as we already have the tracking code deployed on the website, we only have to call the logging JS method: 

ket("action", "Custom_activity_codename")


For example, let’s say you want to log every time someone clicks the call-to-action that I showed you before. You would log the custom activity as follows: 

<a href="http://kentico-roadshow-mvc.azurewebsites.net/en-us/partnership" 
      onclick="ket('action', 'CTA_CO_BecomePartner')">
          <div class="call-to-action__button">Register</div>
</a>


However, Javascript tracking might not be always suitable for your project or it might not be supported by the channel. That’s why Kentico Cloud also comes with REST API for tracking custom activities. This API will allow you to log custom activities from mobile devices, smart assistants as Amazon Alexa and many more. For example if you have an iOS application as a part of your communication channels, your developer might want to check-out our iOS SDK for serving and tracking content. 

Going Advanced 

However, remembering all the custom activity names can be a quite challenging task, especially if you have quite a few of them. If you want to make the life of your developers easier, there’s a few tricks you can use. 

First of all, you can include the name of the custom activity to be a part of the content types you want to track. This way, your developers don’t have to remember the name when they’re logging it in the code but they can access it from the model. Below, you can see an example from our call-to-action.  


<a href="@Url.ActionFromContentItem(Model.InternalContentLink.FirstOrDefault())" 
      onclick="ket('action', '@Model.CustomActivityName')">
                  <div class="call-to-action__button">@Html.Raw(Model.ActionButtonText)</div>
</a>


Moreover, sometimes you might want to track similar content types from the same category. Let’s say you want to track whether your visitors prefer coffee from South America or Africa, so you can then send them a personalized notification when a new roast from the given category arrives at your store.

First of all, we will create a taxonomy that will allow us to tag the coffee category.


Then we will create a custom activity that will have the same codenames as the codenames of the taxonomy terms.


And finally, we will add the new taxonomy to our content model and tag the content items appropriately.


Now that we have everything defined, we can simply log the custom activity.

<a href="@Url.Action("Show", "Coffees", new { urlSlug = featuredCoffee.UrlLabel })"
            onclick="ket('action', '@featuredCoffee.CoffeeCategory')">
                     @Html.Raw(featuredCoffee.CoffeeName)
</a>


I believe these two best practices should help your developers with setting up the custom activities tracking, and also making the code cleaner and highly maintainable.

Moving Forward

Kentico Cloud comes with an out-of-the box tracking API allowing you track your visitors on web, mobile, and various other channels and devices such as Amazon Alexa. In this blog, I showed you how you can set automatic tracking on your website and  log your custom event using the custom activities tracking. In the next article, I’m going to show you how you can leverage the tracked information, define personas and segments, and use them for creating personalized experiences. Meanwhile, feel free to explore the tracking capabilities and stay tuned!