Custom event with custom data that maps with transformation

Current version: 2.1

This is similar to the section Custom event with custom data that maps without transformation, but with the difference that the data from the Sitecore 8.x page event cannot be mapped to the Sitecore 9 custom event without the data being transformed.

Consider an example where, in Sitecore 8.x, you captured a page event when the visitor views a page that displays the status of his membership in a customer loyalty program.

In MongoDB, the page event looks like the following:

RequestResponse
{
    "Name" : "Loyalty program status checked",
    "ItemId" : NUUID("4257b6b4-e263-4356-bba1-9affce442a77"),
    "Timestamp" : NumberLong(0),
    "Data" : "{ \"currentLevel\" : \"silver\", \"pointsToNextLevel\" : \"10000\" }",
    "Text" : "Loyalty program status level for member 100011 is silver",
    "PageEventDefinitionId" : NUUID("5963f929-f278-4784-ba9d-be2fa5b86ae9"),
    "DateTime" : ISODate("2017-11-11T11:00:00.000Z"),
    "Value" : 5
}

In Sitecore 9, you created the following custom event to represent this data:

RequestResponse
using Sitecore.XConnect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MigrationTool.Examples.Loyalty
{
    public class LoyaltyProgramStatusCheckedEvent3 : Event
    {
        public LoyaltyProgramStatusCheckedEvent3(Guid definitionId, DateTime timestamp) : base(definitionId, timestamp)
        {
        }

        public string StatusLevel { get; set; }

        public int PointsToNextLevel { get; set; }
    }
}

You want to implement the following mapping:

Sitecore 8.x property

Sitecore 9 property

Data

StatusLevel and PointsToNextLevel

DateTime

Timestamp

PageEventDefinitionId

DefinitionId

Text

Text

Value

EngagementValue

Do you have some feedback for us?

If you have suggestions for improving this article,