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: which JS is correct?

Avatar

Avatar
Validate 1
Level 2
zloi_dvornik
Level 2

Likes

3 likes

Total Posts

31 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
zloi_dvornik
Level 2

Likes

3 likes

Total Posts

31 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
zloi_dvornik
Level 2

15-10-2015

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?

Replies

Avatar

Avatar
Validate 1000
Community Manager
jantzen_belliston-Adobe
Community Manager

Likes

337 likes

Total Posts

2,286 posts

Correct Reply

815 solutions
Top badges earned
Validate 1000
Springboard
Validate 500
Validate 250
Validate 100
View profile

Avatar
Validate 1000
Community Manager
jantzen_belliston-Adobe
Community Manager

Likes

337 likes

Total Posts

2,286 posts

Correct Reply

815 solutions
Top badges earned
Validate 1000
Springboard
Validate 500
Validate 250
Validate 100
View profile
jantzen_belliston-Adobe
Community Manager

07-06-2017

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