Fatigue rule is implemented in 3 steps:
- Create profile script which evaluates the fatigue limits and keeps track of fatigued activity list.
- Fire an event from Activity/experience to increment view count and also pass the limits.
- Create activity specific audience to exclude user if the activity is part of fatigued activity list.
1. Profile script:
if (mbox.name == 'experience-experience_interaction') {
var listOfFatiguedActivities = user.get('FatiguedActivityList') || '';
var activityName = mbox.param('activityName_FatigueRule');
if (!activityName) {
return listOfFatiguedActivities;
}
var viewsPerActivityKeyName = activityName + 'numberOfViewsFatigueRule';
// if its an interactiion with your experience then increase the profile-script value by 1
var numberOfViewsFatigueRule = parseInt(user.getLocal(viewsPerActivityKeyName)) || 0;
var maxViewsForFatigueRule = parseInt(mbox.param('maxViews_FatigueRule') || 10); // retrieve parameters from mbox
numberOfViewsFatigueRule = numberOfViewsFatigueRule + 1; // increment the view count
user.setLocal(viewsPerActivityKeyName, numberOfViewsFatigueRule); //set the view count against the user profile
user.setLocal(activityName + 'maxViewsForFatigueRule', maxViewsForFatigueRule); //set the max views limit against user profile for reference
if (numberOfViewsFatigueRule < maxViewsForFatigueRule) {
return listOfFatiguedActivities;
} else {
return listOfFatiguedActivities + ',' + activityName;
}
}
2. Here is the custom code for each experience. The below event increments the view count of an activity's experience. We keep this count to implement Fatigue rule for an activity. Fatigue rule is implemented in the profile script.
Custom code block #1 for Activity 1
<script>
adobe.target.trackEvent({
mbox: 'experience-experience_interaction',
params: {
activityName_FatigueRule : 'frtest-p1',
activityId : ${activity.id},
maxViews_FatigueRule: "2"
} });
</script>
Custom code block #2 for activity 2
<script>
adobe.target.trackEvent({
mbox: 'experience-experience_interaction',
params: {
activityName_FatigueRule : 'frtest-p2',
activityId : ${activity.id},
maxViews_FatigueRule: "2"
} });
</script>
3. Create Audience