Expand my Community achievements bar.

DTM Custom Code Data Rules Evaluates Everytime

Avatar

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

Avatar

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.

Avatar

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.

Avatar

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.