5

The following code worked on Sitecore 8.x to increase Engagement Value programmatically:

Tracker.Current.Interaction.Value += value;

This code compiles and executes file on Sitecore 9.0.1, but after flushing my session and looking up the interaction in the xDB Interactions table, the EngagementValue column still has a value of 0. Is there an additional step needed with the Tracker on Sitecore 9?

4

In Sitecore 9.x, the engagement value is a calculated facet.

If you want to increase the engagement value, you should add an event where you are setting the engagement value e.g.

using (XConnectClient client = SitecoreXConnectClientConfiguration.GetClient())
{
  try
  {
    var reference = new IdentifiedContactReference(source, identifier);
    var contact = client.Get(reference, new ExpandOptions());

    int engagementValue = 10;

    var interaction = new XConnect.Interaction(contact, InteractionInitiator.Brand, channelId, userAgent);
    var engagementValueEvent = new Event(Guid.NewGuid(), DateTime.UtcNow)
    {
      EngagementValue = engagementValue
    };
    interaction.Events.Add(engagementValueEvent);

    client.AddInteraction(interaction);

    client.Submit();
  }
  catch (Exception e)
  {
    //
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.