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 Custom Code Data Rules Evaluates Everytime

andrewgats
Level 2
Level 2

It seems like the custom code used within a Data Element is executed every time it is used in a page load and events.  I feel that this could possible pain point for some custom code, especially if it is something that takes a long time to run.  Couldn't the custom code be memorized in the _satellite?

4 Replies
Jeff__Chasin
Employee
Employee

Not sure I follow, but custom script contained in Data Elements should only be run when the DE is called. In other words, when you obtain the value of the Data Element that's returned by the custom code in the

_satellite.getVar("dataElement");

 or in the UI fields.

andrewgats
Level 2
Level 2

Hi Jeff,

My comment is about accessing a data element with with custom code will run that custom code each time.

Say I have a data element of the name, "currentSearchQuery" and it uses custom javascript for its' value.  Every where I access "currentSearchQuery", my custom javascript is run every time.  So if I use it for a rule condition, tag value or calling it directly with _satellite.getVar, my custom javascript is re-run.

Jeff__Chasin
Employee
Employee

Correct. If you want to avoid re-running your custom script on each access of the Data Element, on first run, you can assign the value(s) to a variable or object property and simply reference the variable or object property in subsequent uses.