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 scorings and campaigns.

Personalization Client

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, Leads, and Campaigns. 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 and CampaignClient classes.

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 Task<PersonalizationInfo> GetPersonalizationInfo(string dataSourceName, string subject)
    Returns current information for the requested visitor - ContactProperties, Personas, Leads and Campaigns.
  • public Task<PersonalizationInfo> GetPersonalizationInfo(string dataSourceName, string subject, TimeSpan? timeout)
    Returns current information for the requested visitor - ContactProperties, Personas, Leads and Campaigns.

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.
  • public IList<int> InCampaigns {get; internal set;}
    Contains the identifiers of all Campaigns the visitor participates in.

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 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:

The following sample code demonstrates how to get all personas a subject is associated to, as well as the current score:

Campaign client

Constructors

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

    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 CampaignClient(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

  • public Task<IEnumerable<Campaign>> GetAll(LoadOptions loadOptions)
    Gets all campaigns.
  • public Task<IEnumerable<Campaign>> GetAll(LoadOptions loadOptions, int goalId)
    Gets all campaigns for a goal.
  • public Task<Campaign> GetById(int campaignId)
    Gets a campaign by identifier.
  • public Task<CampaignResult> CheckCampaigns(string dataSourceName, string subject, params int[] campaignIds)
    Checks whether a client is part of campaigns' target audience.
  • public Task<CampaignResult> CheckCampaigns(string dataSourceName, string subject, TimeSpan? timeout, params int[] campaignIds)
    Checks whether a client is part of campaigns' target audience.
  • public Task<bool> CheckCampaign(string dataSourceName, string subject, TimeSpan? timeout, int campaignId)
    Checks whether a client is part of a campaign's target audience.
  • public Task<bool> CheckCampaign(string dataSourceName, string subject, int campaignId)
    Checks whether a client is part of a campaign's target audience.

Sample code

The following sample code demonstrates how to check whether a subject is targeted by a particular campaign or all of the campaigns in Insight:

Was this article helpful?