mtelligent

View Original

Clientside Analytics for Sitecore

Most modern web analytics platforms are primarily clientside driven. Drop a script on your page, use a tagging system like Google Tag Manager or sling your own javaScript to set goals, dimensions and metrics. Sitecore takes a different approach, triggering analytics events server side and providing a robust set of features that allow content authors and adminstrators to configure behaviors.

That being said, being able to trigger a goal, page event or even an interaction client side is a common need and very useful. Unfortunently, Sitecore doesn’t have a client side API for triggering these things, and there are many articles on how to build your own custom endpoints to track things.

With this in mind, I’ve started a new github project called Client Side Analytics for Sitecore to expose a web api capable of working with Sitecore’s analytics API. I’ve also included a JavaScript library that makes it easy to work with it as well as a plugin for Segment’s Analytics JS library which serves as a service bus for client side analytics and tracking events.

I’ve even built a test harness html page that shows you how to use the API, which I demonstrate in this video:

Overview of Initial Release of ClientSide Analytics for Sitecore, a rest API and javaScript library for working with Sitecore analytics features client side.

So what can you do with this API/Library?

  • Get Tracker - Fetches details about current visitor and events/goals triggered for a page request.

  • Identify Contact - Identify the contact as a known contact based on a unique identifier and identifier source.

  • Track Goal - Trigger a Goal configured in Sitecore by Name or Id

  • Track Page Event - Trigger a Page Event configured in Sitecore by Name or Id

  • Track Custom Event - Trigger a Page Event with additional details (think dimension or metric)

  • Track Outcome - Trigger an Outcome with a monetary Value.

  • Trigger Campaign - Trigger a campaign configured in Sitecore by Name or Id.

  • End the Session - End the Session and immediately flush to xDB (Useful for testing)

Github project is located here. There is an initial release which has been tested on Sitecore 9.1. Let me know what you think, and feel free to contribue.