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

My DirectCall inserted a new code every time it is called


Level 1

I have a website developed in Angular (SPA), for each screen I have the trigger of a DirectCall based on a layer of data. In this DirectCall I have only one action configured of the type custom code, responsible for reading the data layer, checking if it is a Custom Link Rule or Page Load Rule and redirecting to another DirectCall, that executes the trigger. But I realized that every time I call this DirectCall I have a push of the code in the DOM HTML. One or the other trigger is not a problem, but because it is a SPA, the user can accumulate many triggers by browsing the website and this will insert more and more code, becoming a problem. Is there any other way to create this router? Is there any extension that will help me with this?

4 Replies


Employee Advisor

Hi Fernando, can you clarify your question? Posting a general idea of what your direct call rules do might also help aid in answering the question.


Level 9

I am also not sure I understand your problem properly, but one hint that might help: You can provide a payload to your direct call rules and you don't have to:

  1. update data layer
  2. trigger a direct call
  3. read data layer

You can just do:

_sattelite.track('direct-call-id', {x: 'y, z: 1});

And in your action you can read it with event.detail.x and event.detail.z


Level 4

Hi Fernando,

Because this custom code is not embedded in the library itself (i.e. the rule isn't triggered by 'Page Top' or 'Page Bottom'), you are seeing the results of using postscribe to execute the custom code.  It's also important to know that this code is executed outside of the timing control of Launch (meaning other Rules and Actions may happen before this postscribed code fully completes, yikes! ).

There's no way I could explain it better than Aaronius9er9er9er​ : So I'd recommend reading his post to grasp how and when postscribe is used. (link below)

Re: Load Order for Rules :: DTM vs. Launch

If you are concerned about the code bloating the DOM, or being visible to the user; you still have plenty of options.  One option would be to execute the custom code in the condition section rather than a custom code action block.  Another option (especially if your goal is collecting data for analytics) would be to group this "reading the data layer" into the specific data elements you plan to use within the "Analytics Set Variables" action block.

There's no single 'best way' or 'standard way' , since all needs and implementations are different - but hopefully this opens up some new possibilities.  If you know exactly what you are doing with the results, that is probably the best place to put this code in a place that's closer to it's use case (like a data element that's referenced in Set Variables).



I have a few questions:

1. Is your custom code JavaScript or HTML?
2. Is the "global" checkbox checked in custom code action?
3. What issue(s) are you noticing with the code being inserted into the DOM each time the custom code action is run?