I need to know if the goal was ever registered on the contact in its any visit on any interaction. How can I do that?

1 Answer 1


Slow approach

You could load all previous visits using this code:

IEnumerable<IInteractionData> visits = Tracker.Current.Contact.LoadHistorycalData(visitsToLoad);

Then you could check every page of every visit and see if the goal was triggered. This would not perform well though.

Fast approach

You should use the Key Behavior Cache which contains (a configurable amount of) goals, events, campaigns etc. that have been triggered by contacts, even in previous visits.

Guid goalId = // your goal ID
KeyBehaviorCache cache = Sitecore.Analytics.Tracker.Current.Contact.GetKeyBehaviorCache();
bool goalTriggered = cache.Goals.Any(_ => _.Id == goalId);

Keep in mind that the Key Behavior Cache contains a limited number of entries. So you should make sure it's tuned for your needs. See this documentation page for more information:

The Key Behavior Cache settings, pipelines, and methods

  • Super! the KeyBehaviorCache variant will work fine for my purposes. Thanks. Commented Dec 7, 2016 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.