Hello @karuppiah_sakthivel ,
Thanks for your reply.
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>
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;
}
}
Since both the custom code blocks are running, View count for experience 2 is also incremented even when the experience is not displayed to user due to it's lower priority.
Note: We would need to increment the view count in a similar way to how Analytics for Target would increment an impression. I am assuming activities with a lower priority do not record an impression in Analytics even though the activity is loaded and higher priority activities are displayed in the browser.
Are you running both of these Activities on your global mbox/location? If so, the global location is configured to return ALL activities that you qualify for and order the return array in accordance with the priority levels. You will have to build custom handling for the "apply" portion of global location.
I would recommend moving to a named mbox / location which is configured to only return ONE thing back to the browser, which should be the higher priority one.