Highlighted

Audience profile script - (visit-based)

simonb23491113 02-08-2019

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

Replies

Highlighted
rajneesh_gautam 07-08-2019

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"

     }

    

}