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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

DTM: which JS is correct?

zloi_dvornik
Level 3
Level 3

Hi All

I am trying to set some variables on a particular page. Page can be identifiable by document.title only.

So I did the following: created a load rule and chose in the Conditions "custom" where I tried to place different versions of the code: 

return ((document.title.match("1.3.3-make-a-payment")? true : false) return (document.title.match("1.3.3-make-a-payment")) ? true : false; return (document.title==“1.3.3-make-a-payment") ? true : false; 
return ((document.title.match("1.3.3-make-a-payment"))? true : false);
return ((document.title.match("1.3.3-make-a-payment"))? true : false)
return ((document.title=="1.3.3-make-a-payment"))? true : false)

The last one returns 'true' in the console but does not work in DTM. 

if (document.title =="1.3.3-make-a-payment"){ var zho = true;} else { var zho= false;} return zho; 

Which one is correct?

Did I use a correct approach?

1 Reply
jantzen_belliston-Adobe
Level 10
Level 10

Hi,

I'm going through some old threads and closing them out.

I'm assuming this question has been answered already, but I'd recommend creating a data element. The data element could have code that pulls the document.title of the page and stores it within the data element. Each rule could then be conditional on the data element equaling a certain value (ie name of the page).

Cheers,
Jantzen