Highlighted

javascript conditions in DTM custom code

Avatar

Avatar

kunjalk3064084

Avatar

kunjalk3064084

kunjalk3064084

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

Highlighted

Avatar

Avatar

pabloc82923542

Avatar

pabloc82923542

pabloc82923542

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?

Highlighted

Avatar

Avatar

Rydal_Williams

Avatar

Rydal_Williams

Rydal_Williams

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.

Highlighted

Avatar

Avatar

kunjalk3064084

Avatar

kunjalk3064084

kunjalk3064084

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?

Highlighted

Avatar

Avatar

Abhijeet_Mishra

Employee

Avatar

Abhijeet_Mishra

Employee

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".

Highlighted

Avatar

Avatar

PratheepArunRaj

Moderator

Avatar

PratheepArunRaj

Moderator

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.

Highlighted

Avatar

Avatar

kunjalk3064084

Avatar

kunjalk3064084

kunjalk3064084

28-01-2018

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

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

Highlighted

Avatar

Avatar

PratheepArunRaj

Moderator

Avatar

PratheepArunRaj

Moderator

PratheepArunRaj
Moderator

28-01-2018

Can you use this instead?

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

Highlighted

Avatar

Avatar

Abhijeet_Mishra

Employee

Avatar

Abhijeet_Mishra

Employee

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'.

Highlighted

Avatar

Avatar

kunjalk3064084

Avatar

kunjalk3064084

kunjalk3064084

29-01-2018

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