Personalization clients

The following article lists Sitefinity Insight .NET SDK personalization clients, along with their constructors, methods, properties, and sample code.

You use these APIs to manage information related to content personalization, such as contact properties and the relationship of visitors to personas, lead scorings, touchpoints and conversions. You use this information to build personalized experiences on your web sites.

PersonalizationClient class

You use the PersonalizationClient class to get information for Visitors and Contacts that you can use for personalization. You use this class to get information, such as Contact properties, Personas, and Leads. To provide this information internally, PersonalizationClass uses one API call, which improves performance. You access this information using one method, instead of using multiple methods from different Insight Client classes.

RECOMMENDATION: We recommend using the PersonalizationClient class instead of the ScoringClient class.

PREREQUISITES: To use the PersonalizationClient class, you need to use Sitefinity Insight .NET SDK 2.0.0 or later. This SDK is compatible with Sitefinity CMS 13.0 and later. If you use the Insight .NET SDK and Sitefinity CMS NuGet packages together in a single project, make sure that you use compatible versions of both packages.

Constructor

  • PersonalizationClient(IAccessToken token, string datacenterKey)
    Initializes a new instance of the PersonalizationClient class using authorization token and datacenter API key.

Methods

  • public async Task<PersonalizationInfoV2> BuildPersonalizationInfo(string dataSourceName, string subject, PersonalizationContext personalizationContext, TimeSpan? timeout)
    Retrieves personalization information for requested visitor, based on the provided context.
    You can query any of the following: contact properties, personas, leads, touchpoints, and conversions.
  • public Task<PersonalizationInfo> GetPersonalizationInfo(string dataSourceName, string subject, TimeSpan? timeout)
    Returns current information for the requested visitor - contact properties, personas, and leads.
    NOTE: If you are using Sitefinity CMS 14.1 and later or .NET SDK 3.4.0 and later, do not use this method. Instead, use the BuildPersonalizationInfo method.
  • public Task<PersonalizationInfo> GetPersonalizationInfo(string dataSourceName, string subject, TimeSpan? timeout)
    Returns current information for the requested visitor - contact properties, personas, and leads.
    NOTE: If you are using Sitefinity CMS 14.1 and later or .NET SDK 3.4.0 and later, do not use this method. Instead, use the BuildPersonalizationInfo method.

PersonalizationInfo class

You use this class to get the complete personalization information that Sitefinity Insight has associated with a given Visitor. To get an instance of this class, use PersonalizationClient.GetPersonalizationInfo() method.

Properties

  • public IDictionary<Guid, string> Properties {get; internal set;}
    Contains all available contact properties for the visitor. The key of the dictionary is the identifier of the Contact property, and the value contains the associated property.
  • public IList<int> InPersonas {get; internal set;}
    Contains the identifiers of all Personas the visitor belongs to.
  • public IList<int> PassedLeadLevels {get; internal set;}
    Contains the identifiers of all completed Lead levels.

PersonalizationEntitiesWithPeriod class

You use the PersonalizationEntitiesWithPeriod class to specify the IDs of touchpoints and conversions and, optionally, the period, which to query personalization information for. The PersonalizationContext class has members of type PersonalizationEntitiesWithPeriod.

Properties

  • public HashSet<int> Ids { get; private set; }
    Contains all IDs of personalization entities that you are querying.
  • PeriodInDays { get; set; }
    The period, in days, which you are querying the personalization entities for.
    The allowed values are -1, 7, 30, 90, 180, and 365. The default value is -1, which means any time.

PersonalizationContext class

You use the PersonalizationContext class to construct a query about personalization entities for a given visitor. Sitefinity Insight returns only the data scoped via the properties of this class, thus making the query lighter and faster to execute.

Properties

  • public bool ContactProperties { get; set; }
    You set this property to true to indicate that you want to query contact properties.
  • public HashSet<int> PersonasIds { get; private set; }
    In this set, you include the IDs of all personas that you want to query.
  • public HashSet<int> LeadsIds { get; private set; }
    In this set, you include the IDs of all lead scorings that you want to query.
  • public PersonalizationEntitiesWithPeriod Touchpoints { get; private set; }
    In this set, you include the IDs of all touchpoints that you want to query, together with the period that you want to return.
  • public PersonalizationEntitiesWithPeriod Conversions { get; private set; }
    In this set, you include the IDs of all conversions that you want to query, together with the period that you want to return.

PersonalizationInfoV2 class

You use this class to get personalization information that Sitefinity Insight has associated with a given visitor. You get instances of the PersonalizationInfoV2 class as a result of successful call of the PersonalizationClient.BuildPersonalizationInfo method.

Properties

  • public bool HasTimedOut { get; set; }
    Indicates whether the request succeeded in the time allotted in the timeout argument of PersonalizationClient.BuildPersonalizationInfo.
  • public IDictionary<Guid, string> Properties { get; set; }
    Contains all available contact properties for the visitor. The dictionary key is the identifier of the Contact property.
  • public IList<int> InPersonas { get; set; }
    A list of identifiers of all personas in which the visitor is recognized.
  • public IList<LeadAndLevelIdentifiers> PassedLeads { get; set; }
    A list of all passed lead scorings and stage identifiers for the visitor.
  • public IList<PersonalizationInfoEntityWithEventDate> InTouchpoints { get; set; }
    A list of all touchpoints touched by the visitor.
    For more information, see PersonalizationInfoEntityWithEventDate below.
  • public IList<PersonalizationInfoEntityWithEventDate> InConversions { get; set; }
    A list of all conversions that the visitor belongs to.
    For more information, see PersonalizationInfoEntityWithEventDate below.

LeadAndLevelIdentifiers class

The LeadAndLevelIdentifiers class represents a lead scoring type and its stages.

Properties

  • public int LevelId { get; set; }
    The stage or the level of a lead scoring.
  • public int LeadId { get; set; }
    The lead scoring ID

PersonalizationInfoEntityWithEventDate class

The PersonalizationInfoEntityWithEventDate class represents the personalization info for a specific personalization entity, such as conversion or touchpoint.

Properties

  • public int Id { get; set; }
    The entity ID.
  • public DateTime LatestEventDate { get; set; }
    The latest date when the event occurred.

PersonalizationInfo class

NOTE: If you are Sitefinity CMS 14.1 and later or .NET SDK 3.4.0 and later, do not use this method. Instead, use the PersonalizationInfoV2 class.

You use this class to get the complete personalization information that Sitefinity Insight has associated with a given visitor. To get an instance of this class, use PersonalizationClient.GetPersonalizationInfo() method.

Properties

  • public IDictionary<Guid, string> Properties {get; internal set;}
    Contains all available contact properties for the visitor. The key of the dictionary is the identifier of the Contact property, and the value contains the associated property.
  • public IList<int> InPersonas {get; internal set;}
    Contains the identifiers of all Personas the visitor belongs to.
  • public IList<int> PassedLeadLevels {get; internal set;}
    Contains the identifiers of all completed Lead levels.

Scoring client

You use the ScoringsClient class to manage the scorings for Personas and Leads.

Constructors

  • public ScoringClient(IAccessToken token, string datacenterKey)
    Initializes a new instance of the ScoringClient class using authorization token and data center API key. Use this class to construct a new instance of the ScoringClient class.

    NOTE: If you are using .NET SDK 3.1.8 or older, in addition to the above constructor, you will also have the following constructor: public ScoringClient(IAccessToken token, string serverAddress, string datacenterKey).
    For later versions of the .NET SDK, this constructor is obsolete and you must replace it with public ScoringClient(IAccessToken token, string datacenterKey).
    For more information, see Capture server side data with .NET SDK.

Methods Personas

  • public Task<IEnumerable<Persona>> GetAllPersonas(LoadOptions loadOptions)
    Gets all personas.
  • public Task<Persona> GetPersonaById(int personaId)
    Gets a persona by identifier.
  • public Task<IPersonaResult> CheckPersonas(string dataSourceName, string subject, params int[] personaIds)
    Checks whether a client is recognized in specified personas.
  • public Task<IPersonaResult> CheckPersonas(string dataSourceName, string subject, TimeSpan? timeout, params int[] personaIds)
    Checks whether a client is recognized in specified personas.
  • public Task<bool> CheckPersona(string dataSourceName, string subject, TimeSpan? timeout, int personaId)
    Checks whether a client is recognized in a persona.
  • public Task<bool> CheckPersona(string dataSourceName, string subject, int personaId)
    Checks whether a client is recognized in a persona.
  • public Task<CollectionResponse<PersonaPoints>> GetPersonaPoints(LoadOptions loadOptions)
    Gets the persona points.
  • public Task<IEnumerable<PersonaScoringStatistic>> GetPersonaScoringStatistics(int scoringId, DateTime from, DateTime to, Scale scale = Scale.Weekly)
    Gets the persona scoring statistics.

Methods Lead scoring

  • public Task<LeadScoringStatistic> GetLeadScoringStatistics(int scoringId, DateTime from, DateTime to, Scale scale = Scale.Weekly)
    Gets the lead scoring statistics.
  • public Task<IEnumerable<LeadScore>> GetAllLeads(LoadOptions loadOptions)
    Gets all leads.
  • public Task<LeadScore> GetLeadById(int leadId)
    Gets a lead scoring by identifier.
  • public Task<ILeadInResult> CheckLeads(string dataSourceName, string subject, TimeSpan? timeout, params int[] scoringIds)
    Checks whether a client is recognized in specified lead scorings.

Sample code

The following sample code demonstrates how to check whether the subject is associated to the first persona or is part of the first lead scoring type in the data center. This sample demonstrates the usage of the PersonalizationContext.BuildPersonalizationInfo method.

Was this article helpful?