Expand my Community achievements bar.

re-usable, global custom JS functions across different rules


Level 1

Is there a way to have have re-usable javascript functions that can be used across various rules (within other custom functions)? Perhaps a new feature in Launch?

It would be pulled in like an include or some other mechanism and be in the same scope as the calling custom function in a rule.


2 Replies


Community Advisor

Private Extensions in Launch should solve your problem:

Private Extensions are Coming!


Community Advisor

Data Elements are your friend.  People often forget that the can return ANY javaScript object (not just strings).


I often use DTM data elements to provide functions or function libraries.

For example, in a DTM (custom code) data element named "func_addTwoNumbers", I might have this:

return function(a, b) {

  return a + b;



Then in a number of places where I want to use this function, I would do this:

var addTwoNumbers = _satellite.getVar("func_addTwoNumbers");

var result = addTwoNumbers(10, 30);

// result will be === 40