I'm trying to create a profile script that checks to see if an element on the current page exists. If the element exists then the code returns true. I'm having difficulty getting my code to work without getting the "element undefined" error. Does anyone have any tips to get this script to work? If accessing page elements through the profile script is not possible; I'm wondering if there is a way to profile users through an offer? Any help is appreciated.
if (mbox.name == 'my_mbox'){ var hasClass = element.classList.contains('.mydiv'); if (hasClass === true) { return true; } }
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Paul,
There are many ways to do this. You can pass your offer code by URL, Page Parameter, mBox Parameter.
By URL : return page.param("offercode"); (Profile Script)
By Page Parameter : (Page level Code)
targetPageParams = function() { return { "offercode": 1451 }; };
Check this https://marketing.adobe.com/resources/help/en_US/target/ov/c_pass_parameters_to_global_mbox.html
By mBox Parameter (Page level Code)
mboxCreate('mboxname','offercode=15463');
Check this https://marketing.adobe.com/resources/help/en_US/target/ov/t_orderconfirm_create.html
You can find the offercode parameter under audience -> visitor profile
Rajarajan R
Views
Replies
Total Likes
Hi Paul,
Script profile code is executed everytime an mbox request is received. If your mbox is defined before the element you want to check, chances are your script execution will return 'element undefined' error.
To avoid this, you can use mboxUpdate() within your offer code. Make sure offer code is set to be executed when target element has been loaded. Example is :
mboxFactoryDefault.addOnLoad(function(){
if (mboxFactoryDefault.getMboxes().get("newMbox").length()===0){
var d = document.createElement("div");
d.id = "newMbox_div";
document.body.appendChild(d);
mboxDefine("newMbox_div","newMbox");
}
mboxUpdate("newMbox","attribute1=value1");
});
You can then set your profiles on the basis of attribute1 and value1. Hope this helps,
Rajneesh
Views
Replies
Total Likes
Thank you for the reply Rajneesh. I'm a bit confused on how I tie the offer code to the profile code. Can you please provide an example?
Views
Replies
Total Likes
Hi Paul,
There are many ways to do this. You can pass your offer code by URL, Page Parameter, mBox Parameter.
By URL : return page.param("offercode"); (Profile Script)
By Page Parameter : (Page level Code)
targetPageParams = function() { return { "offercode": 1451 }; };
Check this https://marketing.adobe.com/resources/help/en_US/target/ov/c_pass_parameters_to_global_mbox.html
By mBox Parameter (Page level Code)
mboxCreate('mboxname','offercode=15463');
Check this https://marketing.adobe.com/resources/help/en_US/target/ov/t_orderconfirm_create.html
You can find the offercode parameter under audience -> visitor profile
Rajarajan R
Views
Replies
Total Likes
Views
Like
Replies
Views
Like
Replies