For developers: Leverage the .NET SDK in the context of Sitefinity CMS
NOTE: Sitefinity Digital Experience Cloud (DEC) was renamed to Sitefinity Insight as a part of the Sitefinity 13.0 release. However, Sitefinity CMS and its documentation prior to version 13.0 continue using the former name - Digital Experience Cloud.
The Progress Sitefinity Digital Experience Cloud connector in Sitefinity CMS provides an easy-to-use infrastructure for creating new handlers, as well as overriding the built-in ones. However, in some cases, you may require custom logic that does not depend on Sitefinity CMS events and requires a custom implementation of sending sentences, metadata, or subject mappings to Progress Sitefinity Digital Experience Cloud. Therefore, you can take advantage of the .NET SDK. Once the Progress Sitefinity Digital Experience Cloud is active after you set the connector settings and credentials, sending of sentences looks similar to the following example:
string
dataCenterKey = Config.Get<DataIntelligenceConnectorConfig>().DataCenterApiKey;
string
dataSource = Config.Get<DataIntelligenceConnectorConfig>().ApplicationName;
SentenceClient sentencecleint =
new
SentenceClient(dataCenterKey);
string
subjectId = ClaimsManager.GetCurrentUserId().ToString();
string
obj =
"page-url/news"
;
string
predicate =
"Has visited"
;
// Built-in predicates used by the built-in handlers may be found here: Telerik.Sitefinity.DataIntelligenceConnector.Models.Predicates
sentencecleint.ImportSentence(dataSource,
new
Sentence() { Subject = subjectId, Object = obj, Predicate = predicate, Timestamp = DateTime.UtcNow });
Apart from the sentence client, you can use the subject mapping client. All these examples apply as-is in the context of a Sitefinity CMS website. Storing and validating the settings in a configuration is a nice addition by Sitefinity CMS in order to enforce good practice about managing configurable data.
In the code example above, you get the user ID as subjectId. This example, however, implies that the user is logged on to your website. If the user is not logged in, you can use the tracking cookie which is automatically created by the Progress Sitefinity Digital Experience Cloud connector. This cookie contains a tracking ID which is used as a subject in a sentence and when the user identifies (for example logs on to the website), a subject mapping that maps the tracking cookie ID and user ID is sent to the cloud.
The following code example demonstrates how to get the tracking cookie value:
using
Telerik.Sitefinity.DataIntelligenceConnector.Cookies;
CookiesManager cookiesManager =
new
CookiesManager();
string
subjectId = cookiesManager.GetCookieValue();
To see detailed information about how to use the .NET SDK, see For developers: Leverage the .NET SDK to capture server side data input.