Skip to content

Instantly share code, notes, and snippets.

@hishaamn
Last active August 28, 2017 21:18
Show Gist options
  • Select an option

  • Save hishaamn/44f1b9d2908a0db4339fde8b6546a7f7 to your computer and use it in GitHub Desktop.

Select an option

Save hishaamn/44f1b9d2908a0db4339fde8b6546a7f7 to your computer and use it in GitHub Desktop.
public class ContentFlowAggregationProcessor : AggregationProcessor
{
protected override void OnProcess(AggregationPipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
VisitData visit = args.Context.Visit;
if (visit.Pages == null || visit.Pages.Count <= 0)
{
return;
}
ContentFlow contentEvents = null;
foreach (PageData page in visit.Pages)
{
if (page.PageEvents == null || page.PageEvents.Count <= 0)
{
continue;
}
foreach (PageEventData pageEvent in page.PageEvents.Where(pe => pe.IsGoal))
{
var itemId = new ID(pageEvent.ItemId);
ContentFlowKey contentFlowKeyObj = new ContentFlowKey
{
Timestamp = visit.SaveDateTime,
ContactId = visit.ContactId,
ItemId = pageEvent.ItemId,
ContentType = Factory.GetDatabase("master").GetItem(new ID(pageEvent.ItemId)).TemplateName,
Type = "A custom type"
};
ContentFlowValue contentViewValue = new ContentFlowValue { Count = 1 };
if (contentEvents == null)
{
contentEvents = args.GetFact<ContentFlow>();
}
contentEvents.Emit(contentFlowKeyObj, contentViewValue);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment