Monthly Archives: February 2013

Click Tracking with Page Events and Sitecore DMS Engagement Analytics

Today, there is an influx of clients starting to use and maximize the capabilities of the Sitecore DMS (Digital Marketing System).  When the true capabilities of the DMS are realized is when you can speak to your clients with passion about how much impact the DMS can have on their business decisions later down the road, which can result in a large ROI.  In addition, your clients will be amazed at flexibility and how easy it is to set up the DMS for subjects such as personalization, campaign tracking, A/B testing, multivariate testing, and so on.

Recently, I have had a couple of clients want to tie in the clicks on their website to their Engagement Analytics report data to understand click tracking behavior of their website visitors.  As a universal solution, you can use JavaScript, a Web Form, Page Events, and the Sitecore API to tie this all together for your clients.

Page Events

Page Events are located here in the Sitecore content tree: /sitecore/system/Settings/Analytics/Page Events.  Content Editors can create as many Page Events as they so choose.

Sitecore Page Events

Sitecore Page Events

In addition, this also applies to Goals, which are located here in the Sitecore content tree: /sitecore/system/Marketing Center/Goals.  Goals are based on the Page Event template and Content Editors can create as many Goals as they want as well.

Sitecore Goals

Sitecore Goals

Whether to use Page Events or Goals for click tracking is a matter of preference but I prefer to use Page Events.  The reason is Goals to me should be used for Conversion activities such as in the example above in Sitecore Goals, “Added Funds To Account”, where this is truly seen as a goal reached.  I see the Page Event in more literal terms, an event, in this case “click”, that happened on a page and that makes sense to me.  However, feel free to mix it up as you see fit with your solution.

Implementation Basics

The first thing you will want to do is create a JavaScript function in an external .js file that is added to the layouts in your Sitecore solution.  This function can be called “TrackClick” or any other meaningful name that you wish to give it.  This function will be called when the “onclick” event is raised on the client-side.  Page events are triggered by their page event name so at a minimum, you must pass in the Page Event name to your JavaScript function.  So the TrackClick function in the “onclick” event would look like this: TrackClick(“Begin Transaction”) assuming that you wanted to trigger the “Begin Transaction” Page Event above in Sitecore Page Events.

Once you have your function in place you will want to make an AJAX call to a Web Form to post the data.  Take a look at the following for more information on making an AJAX call using JavaScript. Using JavaScript versus jQuery or any other library is so that it keeps your tracking solution universal for every client regardless of what JavaScript library they are using.

The Web Form will need to be setup to get the query string values that were passed in from the TrackClick client-side method OnPageLoad.  Ensure the Page Event name is present then you will want to create a PageEventData object and set the properties of the object with the your parameters.  Lastly, you will want to Register the PageEventData object with Engagement Analytics.  Keep in mind that if you have marked the Page Event as a Goal then your PageEventText will show up in the Analytics Reports.  However, if it it set to a failure or system event then the PageEventText will not be there with the registered Page Event in the Analytics Reports.

Take a look at the following Sitecore documentation for registering Page Events with Engagement Analytics.  You will also see in the documentation that you can set more properties of the PageEventData object that will show up in the Engagement Analytics reports once registered.


Now, you  have a universal click tracking solution for any client that is configurable and maintainable by the Content Editors.  All they have to do is go in and create a Page Event and then create and/or modify the onclick event in a link in a field.  This also works for developers as well to get around creating server-side code to handle a server-side click event.  For example, instead of creating a server-side click event to handle the click tracking, now you can consider a client-side solution, which may speed up your coding activities.  Happy coding!