Add custom scoring
The main two pillars of personalization that the Umbraco Engage offers are personas and customer journeys.
The impact of the content page on these can be managed on the Content Score tab in the Personalization app on the top right.
Sometimes you want more fine-grained control over when something does (or doesn't) score. For example, if a user places an order, the user has shifted from the customer journey step "think" to "do".
This might be difficult to accomplish through the Content Scoring UI in Umbraco, but can be done by code.
To manage scoring for personas, we need to get a reference to IPersonaService. For the customer journey, we will need the ICustomerJourneyService. Both services can be found under the namespace Umbraco.Engage.Infrastructure.Personalization.Services.
Both services support two ways to identify entities:
Numeric IDs (e.g.,
personaId,customerJourneyStepId) - Legacy approach using database IDsGUID Keys (e.g.,
personaKey,stepKey) - Preferred approach using Umbraco's GUID-based identifiers
To implement the example above, the ICustomerJourneyService will be used. To modify the customer journey step scoring, the ID or Key of the step being updated must be known. For an implementation, the IDs/Keys can be hardcoded (since they are unlikely to change), or they can be fetched by name through the ICustomerJourneyGroupRepository.
To resolve the required services, we will use Dependency Injection:
ICustomerJourneyGroupRepository _customerJourneyGroupRepository;
ICustomerJourneyService _customerJourneyService;
public MyController(
ICustomerJourneyGroupRepository customerJourneyGroupRepository,
ICustomerJourneyService customerJourneyService) {
_customerJourneyGroupRepository = customerJourneyGroupRepository;
_customerJourneyService = customerJourneyService;
}We will now request Umbraco Engage to provide the customer journey step "Do" from the group "Customer Journey".
Inspect the step Do variable and find its Id or Key. To score the step, provide either the numeric ID or the GUID Key and the score to the CustomerJourneyService:
We have now added a score of 100 to the Customer Journey step "Do". It is also possible to add negative scores. In our example, we can decrease the scores for "See" and "Think".
Since the user is no longer (shifting away) from that step of the Customer Journey the implementation strategy is the same for personas.
Another, more advanced, example could be on how to reset the score of a persona for a given visitor. Use the same approach as above to fetch the persona instead of the Customer Journey for the current visitor. Get the visitor's current score based on the Persona ID or Key, and subtract that exact score from said visitor.
Available Method Overloads
IPersonaService
ScorePersona
(long personaId, int score)
Within HttpContext, using numeric ID
ScorePersona
(Guid personaKey, int score)
Within HttpContext, using GUID key (preferred)
ScorePersona
(Guid visitorExternalId, long personaId, int score, PersonalizationScoreType scoreType)
Outside HttpContext, using numeric ID
ScorePersona
(Guid visitorExternalId, Guid personaKey, int score, PersonalizationScoreType scoreType)
Outside HttpContext, using GUID key (preferred)
ICustomerJourneyService
ScoreCustomerJourneyStep
(long customerJourneyStepId, int score)
Within HttpContext, using numeric ID
ScoreCustomerJourneyStep
(Guid stepKey, int score)
Within HttpContext, using GUID key (preferred)
ScoreCustomerJourneyStep
(Guid visitorExternalId, long customerJourneyStepId, int score, PersonalizationScoreType scoreType)
Outside HttpContext, using numeric ID
ScoreCustomerJourneyStep
(Guid visitorExternalId, Guid stepKey, int score, PersonalizationScoreType scoreType)
Outside HttpContext, using GUID key (preferred)
Last updated
Was this helpful?