Track data server-side

Events tracked out-of-the-box

The table below summarizes the server-side events tracked by the DEC connector out-of-the-box. You can use the events classes and their handler classes to extend or override the default events. All data is reported via the DEC .NET SDK. For more information, see Capture server-side data with .NET SDK.

Event Predicate Object Event class DEC Connector Event Handler Class Supported Sitefinity CMS versions 
Created comment  Post comment  The URL where the comment is posted  Telerik.Sitefinity.Services.Comments.CommentCreatedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.CommentCreatedTrackingHandler 7.x and above
Downloaded document  Download file  The URL of the downloaded file  Telerik.Sitefinity.Modules.Libraries.Web.Events.MediaContentDownloadingEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.MediaContentDownloadTrackingHandler 7.x and above
Submitted form  Submit form  The title of the form submitted Telerik.Sitefinity.Modules.Forms.Events.FormEntryCreatedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.FormEntrySubmittedTrackingHandler 7.x and above
Created forum post  Create forum post under  The URL of the created forum post Telerik.Sitefinity.Forums.Events.ForumPostCreatedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.ForumPostCreatedTrackingHandler 7.x and above
Created forum thread  Create forum thread  The URL of the created thread  Telerik.Sitefinity.Forums.Events.ForumThreadCreatedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.ForumThreadCreatedTrackingHandler 7.x and above
Subscribed to a forum thread  Subscribe to forum thread  The URL of the subscribed forum thread Telerik.Sitefinity.Forums.Events.ForumThreadSubscriptionCreatedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.ForumThreadSubscriptionCreatedTrackingHandler 7.x and above 
Unsubscribed from a forum thread Unsubscribe from forum thread The URL of the unsubscribed forum thread  Telerik.Sitefinity.Forums.Events.ForumThreadSubscriptionDeletedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.ForumThreadSubscriptionDeletedTrackingHandler 7.x and above
Subscribed to email campaign Subscribe to newsletter  The name of the email campaign  Telerik.Sitefinity.Modules.Newsletters.Events.NewsletterSubscriptionCompletedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.NewsletterSubscriptionCreatedTrackingHandler 7.x and above
Unsubscribed from email campaign  Unsubscribe from newsletter The name of the email campaign  Telerik.Sitefinity.Modules.Newsletters.Events.NewsletterSubscriptionDeletedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.NewsletterSubscriptionDeletedTrackingHandler 7.x and above
View personalized widget on page  View personalized widget  An empty string is sent as object  Telerik.Sitefinity.Personalization.Impl.Web.Events.IPersonalizedWidgetRenderEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.PersonalizedWidgetTrackingHandler 8.2 and above
View personalized page  View personalized page The absolute URL of the page Telerik.Sitefinity.Web.Events. PagePreRenderCompleteEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.PersonalizedPageTrackingHandler 7.x and above 
Logged in contact
Login
An empty string is sent as object 
Telerik.Sitefinity.Web.Events.LoginCompletedEvent Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.UserLoginHandler
7.x and above 
Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.LoginMappingHandler 9.x, 8.x, 7.x 
Registered contact  Register 
An empty string is sent as object 
Telerik.Sitefinity.Security.Events.UserRegistered Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.UserRegisteredTrackingHandler 7.x and above
Activated contact  Activate User  An empty string is sent as object Telerik.Sitefinity.Security.Events.ProfileUserUpdated Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.UserActivatedTrackingHandler 7.x and above
Created contact  No predicate is sent  No object is sent  Telerik.Sitefinity.Security.Events.UserCreated Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.UserCreatedTrackingHandler 7.x and above
Created profile  No predicate is sent  No object is sent  Telerik.Sitefinity.Security.Events.ProfileCreated Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.UserProfileCreatedTrackingHandler 7.x and above 
Updated profile  No predicate is sent  No object is sent  Telerik.Sitefinity.Security.Events.ProfileUpdated Telerik.Sitefinity.DataIntelligenceConnector.EventHandlers.UserProfileUpdatedTrackingHandler 10.x and above

Create new data collection handlers

You can extend its core list of tracked events by creating your custom event handler – it is as simple as composing the contents of the request that you send to DEC. In the context of the DEC connector, this request is not considered the structure of the HTTP request but more specifically, the structure of the data you send to DEC.

In the sections below, you can see in details how to create your own data collection handlers, depending on the version of Sitefinity CMS you are working with.

Sitefinity CMS 10.0 and newer

  1. Create a new class that inherits the abstract class InteractionsTrackingHandlerBase<T>, where <T> is one of the default events or a custom class implementing the IEvent interface.
  2. Implement the abstract method List<Interaction> ComposeInteractions(T @event).
  3. Register your new handler in Sitefinity backend by navigating to Administration » Settings » Advanced » DigitalExperienceCloudConnector » ServerHandlers.
  4. Recycle your Sitefinity CMS application.

The sample code below demonstrates how to create a custom handler that reports data to DEC when a new user is created in Sitefinity CMS:

Sitefinity CMS 9.2 and older

  1. To create a new event handler, you simply inherit one of the following classes:
    • SentencesTrackingHandlerBase<T>
    • SubjectMetadataTrackingHandlerBase<T>
    • MappingsTrackingHandlerBase<T>

    Where <T> is the type of Sitefinity CMS event that implements the IEvent interface.

  2. Compose data by implementing the Compose* method of the respective class:
    • ComposeSentences(T theEvent) for SentencesTrackingHandlerBase<T> method
    • ComposeSubjectMetadata(T theEvent) for SubjectMetadataTrackingHandlerBase<T> method
    • ComposeMappings(T theEvent) for MappingsTrackingHandlerBase<T> method
  3. Register the handler in the DEC connector configuration file. To do this:
    1. In Sitefinity CMS, navigate to Administration » Settings » Advanced » DigitalExperienceCloudConnector.
    2. According to the type of event handler class you inherited, register your new handler in the corresponding section:
    • ServerHandlers (for sentence handlers)
    • MappingHandlers
    • SubjectMetadataHandlers
  4. Recycle your application.

The sample code below demonstrates how to create a custom handler that reports data to DEC when a new account is created in Sitefinity CMS:

Customize the out-of-the-box data collection

Sitefinity CMS 10.0 and newer

To customize the out-of-the-box data collection, you simply need to create a custom handler in the SitefinityWebApp project, which inherits from the handler responsible for the event you wish to modify. You need to:

  1. Override the List<Interaction> ComposeInteractions(T @event) method of the handler.
  2. Register the custom handler under Administration -> Settings -> Advanced -> DigitalExperienceCloudConnector -> ServerHandlers.
  3. Recycle your Sitefinity CMS website.

For a comprehensive list of available handler classes you can check the list in the beginning of this article or navigate to Administration » Settings » Advanced » DigitalExperienceCloudConnector » ServerHandlers.

The code sample below demonstrates how to modify the data sent to DEC once a form is submitted:

Sitefinity 9.2 and older

Customizing the out-of-the box handlers in older versions of Sitefinity CMS is similar to the newer versions, with the only difference being that you will need to know which handler to inherit and consequently, which method to override in your new class:

  • SentencesTrackingHandlerBase<T>
    Override the ComposeSentences(T @event) method
  • SubjectMetadataTrackingHandlerBase<T>
    Override the ComposeSubjectMetadata(T @event) method
  • MappingsTrackingHandlerBase<T>
    Override the ComposeMappings(T @event) method

Next, you register your new handler class in the appropriate section under Administration » Settings » Advanced » DigitalExperienceCloudConnector:

  • ServerHandlers for SentencesTrackingHandlerBase<T>
  • MappingHandlers for MappingsTrackingHandlerBase<T>
  • SubjectMetadataHandlers for SubjectMetadataTrackingHandlerBase<T>

Note that some out-of-the-box handlers, for example, LoginMappingHandler and UserCreatedTrackingHandler are internal and cannot be customized.

The sample code below demonstrates how to override the handler for submitting a form:

Work with the .NET SDK in the context of Sitefinity CMS

You can access and instantiate all of the DEC .NET SDK clients within your SitefinityWebApp project, just like you would outside of the project. For more information, see Data collection clients.

When working with the .NET SDK clients  in the context of Sitefinity CMS, it is important to make sure that you use the same settings that the DEC connector uses:

  • Telerik account username and password
  • DEC data center API key
  • Data source to which data is to be reported

The following sections provide you with recommendation about how to work with the .NET SDK, depending on the version of Sitefinity you have.

Sitefinity 10.0 and newer

We recommend using the InteractionManager class for data collection since it guarantees that data is reported using the DEC connector settings.

The following table lists the key properties and methods of the InteractionManager class.

Property/Method Description
public string Source { get; } Gets the DEC data source with which the DEC connector is set up. We recommend that you use this data source to report to DEC all custom interactions to DEC.
public bool IsUserAuthenticated { get; } Checks whether the current user browsing your website is logged in.
public Interaction CreateInteraction(string predicate, string obj, string subject = null) Creates a basic interaction with only a predicate and an object. If a subject is not provided, it is obtained by calling the GetInteractionSubject() method.
public Interaction CreateInteraction(string predicate, string obj, Dictionary<string, string> objectMetadata, Dictionary<string, string> subjectMetadata, string subject = null) Creates an interaction with object and subject metadata. If a subject is not provided, it is obtained by calling the GetInteractionSubject() method.
public Interaction CreateInteraction(string predicate, string obj, string subject, Dictionary<string, string> objectMetadata, Dictionary<string, string> subjectMetadata, string subjectMappedTo) Creates a complex interaction with metadata and mapping.
public Interaction CreateInteractionMapping(string userId, string trackingId = null) Creates a mapping-only interaction. If a tracking ID is not provided, it is obtained by calling the GetTrackingId() method.
public Interaction CreateInteractionSubjectMetadata(string subject, Dictionary<string, string> metadata) Creates an interaction with subject metadata only.
public void SendInteraction(Interaction interaction) Sends the provided interaction to DEC, using the settings with which the DEC connector is set up.
public void SendInteractions(List<Interaction> interactions)
Sends the provided interactions to DEC, using the settings with which the DEC connector is set up.
public virtual string GetInteractionSubject()

Returns the most appropriate subject with which to report your data, based on the following criteria:

  1. If the current user browsing the website is logged in, the method returns the user ID from the Sitefinity CMS database.
  2. If the current user is not logged in and there is a cookie, created by the DEC JavaScript SDK, the subject ID from that cookie is returned.
  3. If the user is not logged in, there is no DEC JavaScript SDK cookie and the user gave consent that their actions on the website are tracked, a new DEC JavaScript SDK cookie is created and the subject ID from it is returned.
public virtual string GetTrackingId()
Returns the tracking ID from the DEC JavaScript SDK cookie. Note that if there is no DEC JavaScript SDK cookie and the user gave consent that their actions on the website are tracked, a new DEC JavaScript SDK cookie is created and the subject ID from the cookie is returned.

The following code example demonstrates how to get an instance of the InteractionManager class and send an interaction with it:

If you want to use some of the DEC .NET SDK clients that need authentication, for example the Personalization clients or A/B test clients, we recommend using the IDataIntelligenceConnectorConfigWrapper interface and the InteractionManager class to make sure that you are using the same settings as the DEC connector.

The following table lists the key properties in the IDataIntelligenceConnectorConfigWrapper.

Property Description
string ApiServerUrl { get; set; }

The URL of the DEC API Server the DEC connector reports data to.

string DecAppUrl { get; set; }
The URL of the DEC Web app.
string TrackingCookieDomain { get; set; }
The tracking domain as set in the DEC JavaScript SDK cookie. For more information, see Manage cookies.
string ApplicationName { get; set; }
The DEC data source with which the DEC connector reports all of the data.
string AccessKey { get; set; }
Returns the access key token that you use to issue an authorization token.
string UserName { get; set; }

IMPORTANT: From Sitefinity 12.1 onward, this property is marked as obsolete. Use the AccessKey property instead.

Returns the username of the Telerik account the DEC connector is set up with.

string Password { get; set; }

IMPORTANT: From Sitefinity 12.1 onward, this property is marked as obsolete. Use the AccessKey property instead.

Returns the password of the Telerik account the DEC connector is set up with. 

bool IsConnected { get; set; }
Indicates whether the DEC connector established a successful connection with DEC.
bool DataCenterApiKey{ get; set; }

IMPORTANT: You use this property when working with Sitefinity CMS 9.2 and older. 

Returns the API Key of the DEC data center with which the DEC connector is set up with.

string GetApiKeyForCurrentSite();

IMPORTANT: You use this property when working with Sitefinity CMS 10.0 and newer. 

Returns the API Key of the DEC data center the current Sitefinity CMS site reports its data to, as per the DEC connector setup.

The following code example demonstrates how to obtain:

  • Instances of the DataIntelligenceConnectorConfigWrapper, which implements the IDataIntelligenceConnectorConfigWrapper interface
  • The InteractionManager classes
  • Properly instantiate the Campaign client from DEC .NET SDK and collect the status of the current subject for all the campaigns in the DEC data center the Sitefinity CMS website reports to

Sitefinity 9.2 and older

We recommend using the SentenceManager, SubjectMetadataManager, and SubjectMappingManager classes. The following tables looks into details into each class and its properties and methods.

SentenceManager

Property/Method Description
bool IsUserAuthenticated { get; }
Checks whether the current user browsing your website has logged in.
string Source { get; }
Gets the DEC data source with which the DEC connector is set up. We recommend that you use this data source to report to DEC all custom interactions to DEC.
Sentence CreateSentence(string predicate, string obj, string subject = null);
Creates a basic sentence with only a predicate and an object. If a subject is not provided, it is obtained by calling the GetSentenceSubject() method.
Sentence CreateSentence(string predicate, string obj, Dictionary<string, string> objectMetadata, Dictionary<string, string> subjectMetadata, string subject = null);
Creates a sentence with a predicate, an object and subject and object metadata. If a subject is not provided, it is obtained by calling the GetSentenceSubject() method.
void SendSentence(Sentence sentence);

Sends a single sentence to the DEC API server.

void SendSentences(List<Sentence> sentences) Sends a list of sentences to the DEC API server.
public virtual string GetSentenceSubject()

Returns the most appropriate subject with which to report your data, based on the following criteria:

  1. If the current user browsing the website is logged in, the method returns the user ID from the Sitefinity CMS database.
  2. If the current user is not logged in and there is a cookie, created by the DEC JavaScript SDK, the subject ID from that cookie is returned.
  3. If the user is not logged in, there is no DEC JavaScript SDK cookie, a new DEC JavaScript SDK cookie is created and the subject ID from it is returned.

SubjectMetadataManager

Property/Method Description
string Source { get; }
Gets the data source with which the DEC connector is set up.
SubjectMetadata CreateSubjectMetadata(string subject, Dictionary<string, string> metadata);
Creates a subject metadata object to be sent to the DEC API server. If you with to send metadata related to the current user browsing the website, we recommend using the GetSentenceSubject() method of the SentenceManager class.
void SendSubjectMetadata(SubjectMetadata subjectMetadata);
Sends a single subject metadata object to the DEC API server.
void SendSubjectMetadata(List<SubjectMetadata> subjectMetadata);
Sends a collection of subject metadata objects to the DEC API server.

SubjectMappingManager

Property/Method Description
string Source { get; }
Gets the data source with which the DEC connector is set up.
SubjectMapping CreateSubjectMapping(string userId, string trackingId = null);
Creates a subject mapping object for the provided IDs. If the trackingId is not provided, it is obtained from the GetTrackingId() method. Note that this method sets both the Source1 and Source2 properties equal to the Source property of the SubjectMappingManager. If the userId is from a different data source than the one the DEC connector is set up with, you can change the Source1 property manually in the subject mapping object returned by the method.
string GetTrackingId();
Returns the tracking ID from the DEC JavaScript SDK cookie. Note that if there is no DEC JavaScript SDK cookie, a new DEC JavaScript SDK cookie is created and the subject ID from the cookie is returned.
void SendMapping(SubjectMapping mapping);
Sends a single subject mapping object to the DEC API Server.
void SendMappings(List<SubjectMapping> mappings);
Sends a collection subject mapping objects to the DEC API Server.

Following is a code example that demonstrates how to obtain and use the SentenceManager, SubjectMetadataManager, and SubjectMappingManager classes.

If you want to use some of the DEC .NET SDK clients that need authentication, for example Personalization clients, we recommend using the DataIntelligenceConnectorConfigWrapper and the SentenceManager classes to make sure you are using the same settings as the DEC connector. The DataIntelligenceConnectorConfigWrapper is described in more details in the Sitefinity 10.0 and newer section of this article.

The following code sample demonstrates how to properly obtain and list the DEC personas the current user browsing your website is associated to.

 

Was this article helpful?