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

javascript conditions in DTM custom code

Avatar

Avatar
Boost 1
Level 2
kunjalk3064084
Level 2

Like

1 like

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Applaud 5
View profile

Avatar
Boost 1
Level 2
kunjalk3064084
Level 2

Like

1 like

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Applaud 5
View profile
kunjalk3064084
Level 2

25-01-2018

Hi,

I am trying to set values in some evars, props and events based on keywords present in the URL in the custom code of a direct call rule. so IF the URL contains xyz or abc, set

if (s.pageURL.indexOf("/xyz")>-1 || s.pageURL.indexOf("/abc")>-1)

{

s.event="event1";

s.prop5=s.eVar5=_satellite.getVar('test');

}

any idea on how to make these conditions work?

Replies

Avatar

Avatar
Give Back 50
Level 6
pabloc82923542
Level 6

Likes

76 likes

Total Posts

358 posts

Correct Reply

81 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Level 6
pabloc82923542
Level 6

Likes

76 likes

Total Posts

358 posts

Correct Reply

81 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
pabloc82923542
Level 6

25-01-2018

What are you trying to understand from a user behaviour perspective for the 2 types of URLs? Can you explain in more detail your desired categorization reporting output?

Avatar

Avatar
Boost 5
Level 4
Rydal_Williams
Level 4

Likes

22 likes

Total Posts

72 posts

Correct Reply

23 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 5
View profile

Avatar
Boost 5
Level 4
Rydal_Williams
Level 4

Likes

22 likes

Total Posts

72 posts

Correct Reply

23 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 5
View profile
Rydal_Williams
Level 4

25-01-2018

Hi, your sudo code looks like you are on the right path - are you having issues, if so what are they?

I'll use document.location instead of s.* though.

Avatar

Avatar
Boost 1
Level 2
kunjalk3064084
Level 2

Like

1 like

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Applaud 5
View profile

Avatar
Boost 1
Level 2
kunjalk3064084
Level 2

Like

1 like

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Applaud 5
View profile
kunjalk3064084
Level 2

28-01-2018

i am getting data for evar and prop but not for the event. is it required to pass values into event after the evar  and prop?

Avatar

Avatar
Boost 5
Employee
Abhijeet_Mishra
Employee

Likes

30 likes

Total Posts

73 posts

Correct Reply

35 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile

Avatar
Boost 5
Employee
Abhijeet_Mishra
Employee

Likes

30 likes

Total Posts

73 posts

Correct Reply

35 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile
Abhijeet_Mishra
Employee

28-01-2018

Hi,

Looks like your event script has syntax error.

You currently have it implemented as s.event="event1", where-as it should be using s.events.

Your script should be s.events="event1".

Avatar

Avatar
Affirm 250
Moderator
PratheepArunRaj
Moderator

Likes

295 likes

Total Posts

836 posts

Correct Reply

253 solutions
Top badges earned
Affirm 250
Contributor
Springboard
Shape 1
Validate 10
View profile

Avatar
Affirm 250
Moderator
PratheepArunRaj
Moderator

Likes

295 likes

Total Posts

836 posts

Correct Reply

253 solutions
Top badges earned
Affirm 250
Contributor
Springboard
Shape 1
Validate 10
View profile
PratheepArunRaj
Moderator

28-01-2018

Because the syntax is not correct.

s.events="event1"; and not s.event="event1"; 's' is missing. Kindly change.

No need to pass the value into the event.

Avatar

Avatar
Boost 1
Level 2
kunjalk3064084
Level 2

Like

1 like

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Applaud 5
View profile

Avatar
Boost 1
Level 2
kunjalk3064084
Level 2

Like

1 like

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Applaud 5
View profile
kunjalk3064084
Level 2

28-01-2018

my bad. it is s.events="event1"

so evar5 and prop5 getting triggered but event1 not getting triggered.

Avatar

Avatar
Affirm 250
Moderator
PratheepArunRaj
Moderator

Likes

295 likes

Total Posts

836 posts

Correct Reply

253 solutions
Top badges earned
Affirm 250
Contributor
Springboard
Shape 1
Validate 10
View profile

Avatar
Affirm 250
Moderator
PratheepArunRaj
Moderator

Likes

295 likes

Total Posts

836 posts

Correct Reply

253 solutions
Top badges earned
Affirm 250
Contributor
Springboard
Shape 1
Validate 10
View profile
PratheepArunRaj
Moderator

28-01-2018

Can you use this instead?

s.events = s.apl(s.events, "event1", ",", 2);

Avatar

Avatar
Boost 5
Employee
Abhijeet_Mishra
Employee

Likes

30 likes

Total Posts

73 posts

Correct Reply

35 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile

Avatar
Boost 5
Employee
Abhijeet_Mishra
Employee

Likes

30 likes

Total Posts

73 posts

Correct Reply

35 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile
Abhijeet_Mishra
Employee

28-01-2018

If the syntax is correct, another factor which could prevent the event from being triggered completely is that your Direct Call Rule is setup to fire an "s.tl()" and your custom code is missing 'linktrackevents'.

Avatar

Avatar
Boost 1
Level 2
kunjalk3064084
Level 2

Like

1 like

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Applaud 5
View profile

Avatar
Boost 1
Level 2
kunjalk3064084
Level 2

Like

1 like

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Applaud 5
View profile
kunjalk3064084
Level 2

29-01-2018

will this have an impact on other events in the same rule?