How to write a profile script for url visited anytime in a session? | Community
Skip to main content
Level 2
April 1, 2025
Solved

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

  • April 1, 2025
  • 1 reply
  • 899 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Utkarsh_Balooni

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 🙂

1 reply

Utkarsh_Balooni
Utkarsh_BalooniAccepted solution
Level 2
April 2, 2025

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 🙂

Utkarsh_Balooni
Level 2
April 2, 2025

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 

Level 2
April 2, 2025

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