Last active
August 28, 2017 21:18
-
-
Save hishaamn/44f1b9d2908a0db4339fde8b6546a7f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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