Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Profile Script - Element exists

Avatar

Avatar
Validate 1
Level 1
paul_anderson
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
paul_anderson
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
paul_anderson
Level 1

20-01-2016

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; } }

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 2
rajarajanr71853
Level 2

Likes

8 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
rajarajanr71853
Level 2

Likes

8 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
rajarajanr71853
Level 2

09-02-2016

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

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 1
paul_anderson
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
paul_anderson
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
paul_anderson
Level 1

05-02-2016

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?

Avatar

Avatar
Validate 1
Level 2
RajneeshGautam-
Level 2

Likes

15 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
RajneeshGautam-
Level 2

Likes

15 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
RajneeshGautam-
Level 2

04-02-2016

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