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.
Solved! Go to Solution.
Views
Replies
Total Likes
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
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
I think we need to add
user.set('YourProfileScriptName','True') as well in Profile snippet above to keep profile script value intact.
Views
Replies
Total Likes
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
but how to pass first this parameters to global mbox using at.js?
var flag=user.get('YourProfileScriptName')||'False';
var Pages = ['HomePage', 'CategoryPage', 'ProductPage'];
if (Pages.includes(mbox.param('page_name'))) {
flag = 'True';
}
return flag;
I assume that these parameters needs to be passed first to at.js in order to filter them in the future?
Views
Replies
Total Likes
Hi @Michael_Soprano ,
That is correct understanding, In above example profile script will look for mbox.page_name parameter in order to set flag as expected.
The mbox.page_name paramter will need to be passed from client side (using at.js)
It should be send like this?
<script>
targetPageParams = function() {
return {
// Property token
"at_property": "5a0fd9bb-67de-4b5a-0fd7-9cc09f50a58d",
// Mbox parameters
"pageName": "product detail"
};
};
</script>
Do I have to put in the bottom something like this?
<script src="mbox.js" type="text/javascript"></script>
This documentation is spectatuliary poor ......
Views
Replies
Total Likes
Hi @Michael_Soprano ,
The syntax for mbox parmater as shared below is correct -
<script>
targetPageParams = function() {
return {
// Property token
"at_property": "5a0fd9bb-67de-4b5a-0fd7-9cc09f50a58d",
// Mbox parameters
"pageName": "product detail"
};
};
</script>
For the second part of adding (Implementing) Adobe Target on Webpage - Assuming you have downloaded "at.js" and have included in same directory as your web-page the self hosted apporach below should work. (If mbox.js is in the same directory as your HTML file)
<script src="mbox.js" type="text/javascript"></script>
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies