Expand my Community achievements bar.

Join us for an upcoming in-person Adobe Target Skill Builders event ~~> We're hosting these live learning opportunities to equip you with the knowledge and skills to leverage Target successfully. Learn more to see if we'll be coming to a city near you!

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

1 Reply

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"

     }

    

}