Expand my Community achievements bar.

SOLVED

Profil script - Counter mbox views

Avatar

Level 1

Hi everyone,

 

I want to configure a profil script who is going to count the number of time that the mbox was viewed by a visitor.

 

After two times that my mbox was viewed by the user, the visitor is no more able to see the activity.

 

Ex : I have an activity that I want only to show to the user two times.

 

name of the mbox = home

 

it's possible to do that by a profil script ? 

activity name = Security Ad

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@A2896 this would be simple, setup a profile script with a name as per your preference and add this code and replace xyz as per mbox id and <<profile-script-name>> placeholder with profile script name. Create audience with visitor profile attributes nd select the profile script name you just created with evaluator as <= with static value comparison as 2. Finally use this audience as eligibility criteria.

 

if (mbox.name == 'xyz') {
        return (user.get(<<profile-script-name>>) || 0) + 1;
    }
}

 

#sample screenshot

 

nnakirikanti_0-1683175824124.png

 

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@A2896 this would be simple, setup a profile script with a name as per your preference and add this code and replace xyz as per mbox id and <<profile-script-name>> placeholder with profile script name. Create audience with visitor profile attributes nd select the profile script name you just created with evaluator as <= with static value comparison as 2. Finally use this audience as eligibility criteria.

 

if (mbox.name == 'xyz') {
        return (user.get(<<profile-script-name>>) || 0) + 1;
    }
}

 

#sample screenshot

 

nnakirikanti_0-1683175824124.png

 

 

Avatar

Level 1

@nnakirikanti  Many thanks for your answer, I'm going to try your solution.  Thanks