Creating a Profile Script to Return True After visiting specific pages using the page name parameter | Community
Skip to main content
February 4, 2025
Solved

Creating a Profile Script to Return True After visiting specific pages using the page name parameter

  • February 4, 2025
  • 1 reply
  • 1149 views

Hi there Adobe Target Experts,

 

I'm looking to create a Profile Script that will return a value of 'true' if a visitor has visited any pages from a group of specific page names.

 

Has anyone done this before at all?

 

Cheers.

Best answer by Vaibhav_Mathur

Hi @SamB2024 , 

I am assuming you're using the at.js configuration approach of Adobe Target. I think the code given below will work for you.

 

var flag=user.get('YourProfileScriptName')||'False'; var Pages = ['HomePage', 'CategoryPage', 'ProductPage']; if (Pages.includes(mbox.param('page_name'))) { flag = 'True'; } return flag;

 

 
Please let me know in case you're using a webSdk approach, I'll share an updated code then.

Hope it helps. 

Best Regards, 
Vaibhav Mathur

Views

 

1 reply

Vaibhav_Mathur
Community Advisor
Vaibhav_MathurCommunity AdvisorAccepted solution
Community Advisor
February 4, 2025

Hi @SamB2024 , 

I am assuming you're using the at.js configuration approach of Adobe Target. I think the code given below will work for you.

 

var flag=user.get('YourProfileScriptName')||'False'; var Pages = ['HomePage', 'CategoryPage', 'ProductPage']; if (Pages.includes(mbox.param('page_name'))) { flag = 'True'; } return flag;

 

 
Please let me know in case you're using a webSdk approach, I'll share an updated code then.

Hope it helps. 

Best Regards, 
Vaibhav Mathur

Views

 
abhinavpuri
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
February 4, 2025

I think we need to add

user.set('YourProfileScriptName','True') as well in Profile snippet above to keep profile script value intact.

Vaibhav_Mathur
Community Advisor
Community Advisor
February 4, 2025

Hi @abhinavpuri , 

Thanks for your response.

We can add user.set('YourProfileScriptName', 'True') additionally here, but it works even if we don’t set it explicitly. .

When a profile script returns a value, that value is automatically stored in the corresponding profile attribute for the user.

In this case, once the script returns 'True', it is saved in the profile attribute 'YourProfileScriptName' for that user, ensuring persistence across visits. The next time the script runs, user.get('YourProfileScriptName') will retrieve the saved value.

Hope it helps. 

Best Regards, 
Vaibhav Mathur