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

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

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