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

DTM: Writing Custom Condition for Page Load Rule

Avatar

Avatar
Validate 10
Level 2
OwlyChick
Level 2

Like

1 like

Total Posts

37 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 10
Level 2
OwlyChick
Level 2

Like

1 like

Total Posts

37 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile
OwlyChick
Level 2

15-10-2015

I can't seem to find any documentation on the form that the custom script needs to be written for conditions on the page load rule. I'm trying to write a page load rule for my error page to set the pageType=error page. The rule is not loading at all from what I can tell. When I put the code from the condition into my console, I can see that my variable "myBool" fires as true, so my code is correct (I think!)

For the condition, I am basing it on our H1 tag to identify the page (triggered at bottom of page):

is404 = function () {

    var myBool = false;
    var myH1 = document.getElementsByClassName("hero-title")[0].innerHTML.toString();
    if (myH1 == "The information you are trying to access has moved." ) {
        myBool = true;
    }
    return myBool;

}
is404();

 

Then in the rule portion for Adobe Analytics, I am setting the custom page code to:

var s= window.s||s;
s.pageType=errorPage;

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Engage 1
Employee
Jeff__Chasin
Employee

Likes

12 likes

Total Posts

36 posts

Correct Reply

12 solutions
Top badges earned
Engage 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Engage 1
Employee
Jeff__Chasin
Employee

Likes

12 likes

Total Posts

36 posts

Correct Reply

12 solutions
Top badges earned
Engage 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Jeff__Chasin
Employee

15-10-2015

When using Custom Script in a Rule Condition, you need to return (boolean) true when you want the Rule to fire.  Try this:

var myH1 = document.getElementsByClassName("hero-title")[0].innerHTML.toString(); if (myH1 == "The information you are trying to access has moved." ) { return true; }

Answers (3)

Answers (3)

Avatar

Avatar
Validate 10
Level 2
OwlyChick
Level 2

Like

1 like

Total Posts

37 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 10
Level 2
OwlyChick
Level 2

Like

1 like

Total Posts

37 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile
OwlyChick
Level 2

15-10-2015

Does anyone have any examples of code they've written in the custom code section of the conditions? I want to make sure I've written the true statement correctly.

Avatar

Avatar
Validate 10
Level 2
OwlyChick
Level 2

Like

1 like

Total Posts

37 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 10
Level 2
OwlyChick
Level 2

Like

1 like

Total Posts

37 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile
OwlyChick
Level 2

15-10-2015

Added quotes, but no luck 😞 It still isn't firing. Thanks for the suggestion!

Avatar

Avatar
Validate 1
Level 4
mikethompson
Level 4

Likes

62 likes

Total Posts

102 posts

Correct Reply

14 solutions
Top badges earned
Validate 1
Shape 1
Shape 10
Boost 50
Boost 5
View profile

Avatar
Validate 1
Level 4
mikethompson
Level 4

Likes

62 likes

Total Posts

102 posts

Correct Reply

14 solutions
Top badges earned
Validate 1
Shape 1
Shape 10
Boost 50
Boost 5
View profile
mikethompson
Level 4

15-10-2015

Could missing quotes around errorPage be causing the problem?