I want to prevent goal from triggering multiple times.
What should I do?
Any suggest?
Thank you.
I tried:
I want to prevent goal from triggering multiple times.
What should I do?
Any suggest?
Thank you.
I tried:
Assumption
Once the goal has been triggered by a visitor, the visitor cannot trigger the same goal.
Solution
If you are triggering the goal programmatically, you can check if the user has already trigger the goal. The below snippet can be used to check if the goal has been triggered.
Guid goalId = // your goal ID
KeyBehaviorCache cache = Sitecore.Analytics.Tracker.Current.Contact.GetKeyBehaviorCache();
bool goalTriggered = cache.Goals.Any(a => a.Id == goalId);
If the goal is being triggered via rules, implement a new rule to perform the check if the goal has been triggered.
Moreover, if you are using Outcomes, you can change the above code to check if the user is already assigned a specific outcome.
Guid outcomeId= // your outcome ID
KeyBehaviorCache cache = Sitecore.Analytics.Tracker.Current.Contact.GetKeyBehaviorCache();
bool isAssociatedOutcome = cache.Outcomes.Any(a => a.Id == outcomeId);
KeyBehaviorCache
has been deprecated.
Commented
Jan 11, 2019 at 12:15