How to get all goals triggered during Sitecore session in commitDataSet Analytics pipeline?

360 Views Asked by At

I have an Analytics pipeline added just before the standard one in section to delete duplicate triggered pageevents before submitting all to database so I can have unique triggered events as there seems to be a bug on android/ios devices that triggers several events within few seconds interval.

In this custom pipeline I need to get the list of all goals/events the current user triggered in his session so I can compare with the values in dataset obtained from args parameter and delete the ones already triggered.

The args.DataSet.Tables["PageEvents"] only returns the set to be submitted to database and that doesn't help since it is changing each time this pipeline runs. I also tried Sitecore.Analytics.Tracker.Visitor.DataSet but I get a null value for these properties.

Does anyone knows a way how to get a list with all goals the user triggered so far in his session without requesting it directly to the database ?

Some code:

 public class CommitUniqueAnalytics : CommitDataSetProcessor
        { 
            public override void Process(CommitDataSetArgs args)
            {
                Assert.ArgumentNotNull(args, "args");
                var table = args.DataSet.Tables["PageEvents"];
                if (table != null)
                {
                   //Sitecore.Analytics.Tracker.Visitor.DataSet.PageEvents - this list always empty
                  ...........
                }
            }
        }
1

There are 1 best solutions below

0
On

I had a similar question.

In Sitecore 7.5 I found that this worked:

Tracker.Current.Session.Interaction.Pages.SelectMany(x=>x.PageEvents)

However I'm a little worried that this will be inefficient if the Pages collection is very large.