Skip to main content
OwlyChick
Level 3
October 16, 2015
해결됨

DTM: Writing Custom Condition for Page Load Rule

  • October 16, 2015
  • 4 답변들
  • 3071 조회

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;

이 주제는 답변이 닫혔습니다.
최고의 답변: Chasin

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

4 답변

Chasin
Adobe Employee
ChasinAdobe Employee답변
Adobe Employee
October 16, 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; }
OwlyChick
OwlyChick작성자
Level 3
October 16, 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.

OwlyChick
OwlyChick작성자
Level 3
October 16, 2015

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

Level 4
October 16, 2015

Could missing quotes around errorPage be causing the problem?