Looking at the OP, the comments, your code and Sitecore's, I believe that this issue is likely caused by a bug in the
PageEvent.IsGoal property, whereby the property is not being correctly set to
true for events that are goals. I have not yet confirmed this bug, but if I am correct then the following should help you work around the issue:
Try changing your code to the following:
foreach (PageData page in args.Context.Visit.Pages)
if (page.PageEvents != null && 0 < page.PageEvents.Count)
foreach (var pageEvent in page.PageEvents)
var pageEventItem = pageEvent.PageEventDefinitionId != Guid.Empty
if (pageEventItem == null || !pageEventItem.IsGoal)
throw new Exception("I must be null because I definitely should be a goal. Still I should never be thrown because I came from the Goals property of the trackers definition items");
Log.Info("Goal: " + pageEvent.Name.ToString(), "PageEventProcessor");
// now do something with your goal
Notice that in the above solution, I am using the
pageEventItem.IsGoal property instead of the
pageEvent.IsGoal property. I have not sufficiently tested this to figure out if the problem is simply with the
PageEvent.IsGoal flag is not set when you check it, but I expect that to be the case. Regardless, the
PageEventItem.IsGoal should be accurate and more reliable, as that property is read directly from the item's field.
Arrival at Solution
While I am still working to figure out if this is actually a bug in xDB, I came to this solution by looking at how Sitecore aggregates goals in the
Remember that a Goal is really a conversion, and since there weren't any processors with "Goal" in the name, I had a look at the
After reviewing the processor I realized that Sitecore's approach was nearly identical to yours though slightly different - Sitecore's code uses the item's field to determine if it's actually a goal. Since checking the value of that field should be more reliable than a property that may or may not have been correctly set on a C# object, I am left to infer that the issue is likely a bug in Sitecore with the
PageEvent.IsGoal property and that you should work around the issue by using the
PageEventItem.IsGoal property, instead.
The first thing that I recommend you do is try the above workaround. Next, I would get in touch with Sitecore Support and show them what you've tried and what you are seeing. They should be able to provide further assistance, in addition to documenting and fixing the bug, if confirmed.