sitecoresitecore8sitecore-xdb

How can I remove duplicated page events in Sitecore 8.1?


I have a processor in the <registerPageEvent> pipeline that checks whether an event is duplicated and removes it. It works well on 7.2, but I have to upgrade to 8.1 Update 3 and I can't find a way to remove an already added page event. Is this possible and how can I do that?

Piece of code from 7.2:

Tracker.Visitor.DataSet.PageEvents.Rows.RemoveAt(Tracker.Visitor.DataSet.PageEvents.Count - 1);

Solution

  • You cannot remove events via the API starting from Sitecore 7.5. (The only way around would be to use .NET reflection)

    Even in 7.2, doing this was a bad idea. The reason being, when an event is added via the API, some internal logic is applied - e.g. the visit's total value is recalculated. If you remove an event manually, these internal actions will not be triggered, and hence, your visit data may end up in an inconsistent state.

    The best approach for you would be to add checks in the code that registers your events - an event should only be registered if it's not a duplicate of an existing event.