Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards
SOLVED

How to write a profile script for url visited anytime in a session?

Avatar

Level 2

Hi, I am currently using the "Site Pages: Landing page URL" + "Visitor Profile: Not first page of session" to target an audience of users who started on a specific page during their session. I would like to change this from landing page to the user having visited at any point in the session - how would I achieve this? I suspect this would require a profile script but am not well-versed in how to write those. Thanks in advance

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi @madhuraj87 ,

As I understand it, you need to create an audience of visitors who visited a particular URL on your website during a given session. To achieve this you can create the following profile script (page_visited):

var desired_url = 'https://abc.com';  //enter your desired page URL
var sessionIdcur = user.getLocal('sessionIdcur') || null; //get the current sessionId

//retrieve the value stored in your profile script, default value is 'false'
var page_visited = user.get('page_visited') || false;  
                                                       
// check if the user starts a new session using the current sessionID stored
if (sessionIdcur !== user.sessionId) {                
  
//set the new session ID value                                                      
  user.setLocal('sessionIdcur', user.sessionId);
  page_visited = false; // Reset page visit for a new session
}
 
if (page.url == desired_url) {
  page_visited = true; // Set to true if the user visits the page
}

return page_visited;

 

Let me know if that solves your issue 🙂

View solution in original post

4 Replies

Avatar

Correct answer by
Level 2

Hi @madhuraj87 ,

As I understand it, you need to create an audience of visitors who visited a particular URL on your website during a given session. To achieve this you can create the following profile script (page_visited):

var desired_url = 'https://abc.com';  //enter your desired page URL
var sessionIdcur = user.getLocal('sessionIdcur') || null; //get the current sessionId

//retrieve the value stored in your profile script, default value is 'false'
var page_visited = user.get('page_visited') || false;  
                                                       
// check if the user starts a new session using the current sessionID stored
if (sessionIdcur !== user.sessionId) {                
  
//set the new session ID value                                                      
  user.setLocal('sessionIdcur', user.sessionId);
  page_visited = false; // Reset page visit for a new session
}
 
if (page.url == desired_url) {
  page_visited = true; // Set to true if the user visits the page
}

return page_visited;

 

Let me know if that solves your issue 🙂

Also please note that according to Adobe Target, by default a session expires after 30 minutes of inactivity - https://experienceleague.adobe.com/en/docs/core-services/interface/data-collection/cookies/target 

Avatar

Level 2

Thank you! When creating an audience using this profile script, should I be selecting "parameter present" or "parameter value is present"?

Avatar

Level 2

You should select equals (true or false).