Beta Version

BLOG

Shamsher Singh Dhillon
7 Minute read

Sitecore Universal Tracker

Sitecore Universal Tracker

In the recent releases, Sitecore has moved from a Monolith software approach to a Micro service based one. We have already seen this in other modules like Sitecore Javascript Services(JSS) and Sitecore Cortex. The Sitecore Universal Tracker is a headless API Micro service to track data from mobile apps, IoT, AR, VR and other emerging channels into Sitecore xDB.

Universal Tracker is a collection of services that allow capturing of data across multiple channels, as and when the interactions happen

You might ask yourself, isn’t that xConnect? No, its not. xConnect only accepts immutable history and is designed for trusted service communication – Authentication only, no authorization. Universal Tracker is required to not expose xConnect. Hence, the universal tracker allow capturing of data from multiple channels like Sitecore Websites, Non – Sitecore Websites, Mobile Devices, IoT devices etc. The key difference between xConnect and Universal Tracker is that whereas xConnect collects information regarding completed interactions, Universal Tracker collects information as soon as the interactions occur and submits those to xConnect, when complete.

                                                

Architecture

There are 3 major components of Sitecore Universal Tracker:      

  1. Collection Service – A.Net Core Web API service, as the name suggests, is responsible for the collection of interactions/events from various channels and stores them temporarily in SQL.
  2. Processing Service – A .Net Core Web API service processes the interactions captured by  the Collection service and sends the processed interactions to Sitecore xConnect. The interactions are processed by channels and custom filters can be defined for each channel.
  3. Interaction Cache – A component that consists of database schemas for MS SQL and Azure databases, where the interactions are stored temporarily before being handed over to xConnect.

                               

There are 3 Pipelines that can be used to manipulate the interactions data.

  • Pre-filter – To filter out interactions, aggregate multiple interactions etc.
  • Enrichment – To manipulate the interactions, add extra information if required.
  • Post-filter – To process the final data before it is sent to xConnect.

OOTB all these pipelines are empty.

Scaling

The Universal Tracker is built to scale. All the components along with the Universal Tracker itself can be scaled to suit the needs of any environment. There can be multiple collection services, in case there are numerous channels. The processing service can be scaled if the data being captured is large, compared to the data being sent to xConnect.

Scaling Collection Service

A scenario that has numerous interactions but low processing:

                                            

Scaling Processing Service

A scenario where the number of interactions is less, but the data is processed heavily before being sent to xConnect.

                                               

Scaling Universal Tracker

Total scaling to have multiple instances of Universal tracker.

                                               

Implementation

After setting up the Sitecore Universal Tracker by following the guide, there should be two new services; one for Processing and one for Collection along with a new database in SQL server.

Processing Service

The status page of the processing service displays connections for both the SQL Server and xConnect Client as the processing server interacts with both services.

Collection Service

The Collection status page only displays the connection to the SQL server, as it does not directly communicate with the xConnect client.

Before starting, we need to check a few things.

  1. The channel that is to be used must be registered with the Universal Tracker.

In the Universal Tracker, only Web, Offline and Mobile channels are registered. If you use any other channel, it needs to be registered with Universal Tracker in the following configuration.

\Sitecore.Tracking.Processing.Service\sitecore\Sitecore.Tracking.Processing.ChannelManagement\PipelinesConfig\channelTypes.json
  1. Anonymous contacts are being indexed by xConnect.

If you want to index anonymous contacts visiting the website, we need to enable IndexAnonymousContactData setting in the following configs:    

xconnectpath\root\App_data\jobs\continuous\IndexWorker\App_data\Config\Sitecore\SearchIndexer\sc.Xdb.Collection.IndexerSettings.xml

xconnectpath\root\App_data\Config\Sitecore\SearchIndexer\sc.Xdb.Collection.IndexerSettings.xml

  1. Disabling WebVisitFilter

Since the interactions captured by Universal Tracker are not Page Views or Web visits, these interactions are filtered out by the WebVisit Interaction Filter. In order to disable this filter, go to the following config.

sitecorewebpath\App_Config\Sitecore\ExperienceAnalytics\Sitecore.ExperienceAnalytics.Aggregation.config

and key in the following line.

<InteractionFilter type="Sitecore.ExperienceAnalytics.Aggregation.Filters.WebVisitFilter, Sitecore.ExperienceAnalytics.Aggregation" />

Submitting Interactions

Interactions in Universal Tracker can be submitted either by using the Sitecore provided SDK or Postman.

Sitecore SDK

Here are the steps to send an Interaction to Universal Tracker using Sitecore SDK.

  1. Create a project in Visual Studio. This can be a desktop application, console application or any other.
  2. Install Sitecore Mobile SDK for Universal Tracker for the project using Nuget Package Manager.
  3. Add the following code to the Main function of the Application.

private static void Main(string[] args)
string instanceUrl = "http://sitecore.tracking.collection.service";
string channelId = "27b4e611-a73d-4a95-b20a-811d295bdf65";
string definitionId = "01f8ffbf-d662-4a87-beee-413307055c48";
var defaultInteraction = UTEntitiesBuilder.Interaction()
                                           .ChannelId(channelId)
                                           .Initiator(InteractionInitiator.Contact)
                                           .Contact("jsdemo", "demo")
                                           .Build();
using (var session = SitecoreUTSessionBuilder.SessionWithHost(instanceUrl)
      .DefaultInteraction(defaultInteraction)
                                   .BuildSession())
{
                var eventRequest = UTRequestBuilder.EventWithDefinitionId(definitionId)
                                                   .Timestamp(DateTime.Now).Build();
                var eventResponse = await session.TrackEventAsync(eventRequest);
                Console.WriteLine("Track EVENT RESULT: " + eventResponse.StatusCode);
}

                instanceUrl 🡺Url of the UAT collection service.
                channelId 🡺 Guid of the channel used. This needs to be registered with Universal Tracker.
                definationId 🡺 Guid of the event to be triggered (Goal, Outcome etc.)
  1. The following references need to be added for the code to work properly.

using System;
using System.IO;
using System.Threading.Tasks;
using Sitecore.UniversalTrackerClient.Entities;
using Sitecore.UniversalTrackerClient.Request.RequestBuilder;
using Sitecore.UniversalTrackerClient.Session.SessionBuilder;
  1. If everything is setup correctly, you should be able to see the following output:



    More information regarding the Universal Tracker SDK can be found here

Postman

You can begin the submission of interactions to Universal Tracker, directly from Postman without writing a line of code.

Here are the available endpoints that can be used to submit or edit Interactions to Universal Tracker.

  1. Initiating Interaction

Endpoint: CollectionServiceUrl/interaction
Request Type: PUT
Request Body:
{
                “Initiator”:””,                                         //brand or contact
                “ChannelId”:””,                                     //channel id to be used 
                “UserAgent”:””,                                     //user agent info
                “Contact”: {
                                “Source”:””,                           //contact reference source
                                “Identifier”:””                        //contact reference identifier
//If the contact with specified source and identifier is not found, a new contact will be created for same.
},
                “Events”:{
                                “type”:””,                               //type of event; goal, outcome etc.
                                “definitionId”:””,   //guid of the event type
                                “Timestamp”:””                     //timestamp when the goal was triggered.
}
}
Response Code: 201
Response Content:
Tracking Interaction Id                                         //this interaction id is used for subsequent additions 

and submitting the interaction                

Sample

  • Adding Events to existing Interaction
  • 
    Endpoint: CollectionServiceUrl/event
    Request Type: PUT 
    Request Body:
    [
                    {
                                    “type”:””,                                               //type of event; goal, outcome etc.
                                    “definitionId”:””                    //guid of the event type
                                    “Timestamp”:””                                     //timestamp when the goal was triggered.
                                    “TrackingInteractionId”:””   //tracking interaction id of the existing 
    interaction.
                    },
                    {
                                    “type”:””,                                               //type of event; goal, outcome etc.
                                    “definitionId”:””                    //guid of the event type
                                    “Timestamp”:””                                     //timestamp when the goal was triggered.
                                    “TrackingInteractionId”:””   //interaction id of the existing interaction.
                    }
    ]
    Response Code: 201
    Response Content:
    Empty                                                                                     //An error would appear if the tracking 
    interaction id is not valid or the interaction
    with the tracking id is not found.
                    
    
    Sample

    1. Closing Interactions
    
    Endpoint: CollectionServiceUrl/interaction/complete
    Request Type: POST
    Request Body:
    {
                    TrackingInteractionId
    Response Code: 202
    Response Content:
    true                                                                                         //An error would appear if the tracking 
    interaction id is not valid or the interaction
    with the tracking id is not found.
    

                    Sample:

    The interactions are not processed in real time but we can modify some settings in Sitecore.Tracking.Processing.Service\sitecore\Sitecore.Tracking.Processing.Engine\Config\config.xml to make it more efficient.

    Experience Profile

    You should be able to view the Interactions along with the events submitted from Postman, on the experience profile of the recently created contact.

    Altudo is a Sitecore Platinum partner with 500+ Sitecore projects delivered for 45+ Fortune 500 brands, across 7 industry verticals
    We help you realize the true potential of your marketing efforts, speeding up the Time to Value by leveraging CX strategy, 1:1 personalization & our global delivery expertise.

    Shamsher Singh Dhillon Associate Technical Lead - Altudo


    Browse Topics

    Talk to our Experts

    Talk to us about how we bring together 1:1 personalisation, deep Martech Expertise, CX & Demand Gen Strategy, Engagement Analytics & Cross-Channel Orchestration to drive award winning experiences that convert

    Get in touch for a complimentary consultation or a demo today.

    Expert Workshops

    Free workshops, expert advice & demos- to help your realize value with Sitecore

    Register

    Session Presentations

    • Sitecore + SFMC= Marketing Success
    • Transforming The Future Of eCommerce
    Meet Us

    Giveaways:

    Participate in our event survey , meet us at our booth , get free giveaways & a chance to win an iPhone 11

    Let’s go