(WIP) Why add custom JS inside your tracking plan?
The Custom JavaScript variable is surely the most versatile variable in the set. You can use it to run arbitrary JavaScript on the page. It creates a script context, meaning you can also call other variables from within using the appropriate syntax.
The Custom JavaScript variable needs to follow two simple rules. First, the script must be wrapped in an anonymous function block (function() { ... }). Second, the function must have a return statement (return somevalue;).
The third, unwritten rule is that the function should only return a value. You shouldn’t use a Custom JavaScript variable to modify the global namescape by pushing values to dataLayer for example. If you want to tamper with global variables from a function, it’s better to create a Custom HTML tag for this purpose.
For further information regarding Custom JavaScript please consider reading through the below links:
How to create custom JS to your tracking plan?
In order to create a custom JS and add to your tracking plan first you need to read the article about adding custom variables.
Please note that:
You will need to choose “Custom Javascript’ as the variable type and then create your code.
Your Custom JavaScript must return some value
Once all the details have been defined simply click "Add" and the variable will be added.
In case you need further assistance please reach out to the J+ Track team on slack channel #help-jplus-track

