Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

The 1st edition of the Target Community Lens newsletter is out now! Click to the right to find all the latest updates

Audience profile script - (visit-based)

Avatar

Level 2

Hi

I want to create an audience profile script - and asking for someones help and expertise please!

In Target I can get the out-of-the-box "previous page" audience rules, but instead of just being their immediate previous page' I want this to apply for their full visit/session i.e. user has browsed through "<url>" within current visit.

Could someone please help me share or write a profile script rule that will do this?

Thanks

0 Replies

Avatar

Community Advisor

Hi simonb23491113​,

Since Adobe Target doesnt have any notion of Visits, you can use proxy of 30 mins since  your target page visited. In that case, following code can help:

if (page.url != "") {

     if (page.url.indexOf("<provide some rule here>") >-1) {

           user.setLocal('last_time_page_visited', new Date().getTime()); //Reset the time when your target page is visited

      }

}

var minutesInMillis = 1000 * 60

var last_time_page_visited = user.getLocal('last_time_page_visited');

if (last_time_page_visited) {

     var time_since_last_visit = ((new Date()).getTime()-last_time_page_visited)/dayInMillis; // This gives number of minutes since your target page visited.

     if (time_since_last_visit < 30) {

          return "true"; //Return true if target page is being visited in the same visit

     }

     else

     {

          return "false"

     }

    

}