Expand my Community achievements bar.

SOLVED

Custom code: Only first declared eVar setting

Avatar

Level 5

Hi there,

I have a strange situation. I have a direct call rule that fires after a data element change rule. In this direct call rule I set a bunch of eVars.

I was setting them in the eVars section of the rule builder. When testing I could see the eVars populating in both the network requests and Omnibug. However I wanted to change it to minimise the risk of sending in unspecified values.

So I added to my custom code the following type of rule for each eVar I wanted to set:

var dataElementName = _satellite.getVar("dataElementName");

if(dataElementName) {

   s.linkTrackVars = "eVar1";

   s.eVar1 = dataElementName;

}

However, this only works if I add one rule of this type to the custom code. As soon as I add another rule with the same syntax it doesn't set either eVar. It's almost like it can't see them at all.

We use this kind of thing a lot in our custom code and it works reliably. I can't understand why in this situation it's not setting the eVars.

Any help would be greatly appreciated

1 Accepted Solution

Avatar

Correct answer by
Employee

Hey Philip,

 

The s.linkTrackVars variable is a string containing a comma-delimited list of variables that you want to include in link tracking image requests ( tl() method). I believe the reason eVar is not set when same piece of code is written again is because it resets value of linkTrackVars.

 

For instance:

 s.linkTrackVars = "eVar1";

s.eVar1 = dataElementName;

will set eVar1

 

s.linkTrackVars = "eVar2";

s.eVar2 = dataElementName;

this will only set eVar2

 

To fire both the variables on the same server call, the syntax should be:

 

s.linkTrackVars = "eVar1,eVar2";

So, in gist you would need to append the values in linkTrackVars than resetting it to new one.

Hope this helps!

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

Hey Philip,

 

The s.linkTrackVars variable is a string containing a comma-delimited list of variables that you want to include in link tracking image requests ( tl() method). I believe the reason eVar is not set when same piece of code is written again is because it resets value of linkTrackVars.

 

For instance:

 s.linkTrackVars = "eVar1";

s.eVar1 = dataElementName;

will set eVar1

 

s.linkTrackVars = "eVar2";

s.eVar2 = dataElementName;

this will only set eVar2

 

To fire both the variables on the same server call, the syntax should be:

 

s.linkTrackVars = "eVar1,eVar2";

So, in gist you would need to append the values in linkTrackVars than resetting it to new one.

Hope this helps!