Custom code in "Set Variable" section executing asynchronously

Avatar

Avatar

rupaljain2408

Avatar

rupaljain2408

rupaljain2408

09-05-2019

Hi All,

We have recently migrated our property from Adobe DTM to Launch. I have a direct call rule, in which evars and props are set using mapping at UI level in Launch, however events and products are set in the custom code of same section "Set Variables" under Action in launch.

Now , the call to DCR has been written like this in code controller :

try {

      window._satellite.track('commonsPageLoad');

    } catch (error) {

      console.error(error);

    } finally {

      window.digitalData = {};

    }

Here, before DCR fully gets executet ,i.e., before image request getting fired , datalayer gets emptied from finally block. It results in loss of data , when image request is fired

Is it due to custom code executing asynchronously ? Can anyone please help on this, what needs to be done.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

gflare

Avatar

gflare

gflare

16-05-2019

The direct call is made in a synchronous manner - but you can think of all the subsequent activity of the rule running afterwards. The execution of another Rule Trigger is completely external to the initial direct call line, so there's no control on timing there.

If you need to control the timing, you do have a few options...

Option 1 (do it yourself): create your own callback, promise, or other control alongside your DCR to ensure it does no continue until the timing you desire.

Option 2 (let Launch do it): If you perform this same type of call in a series of conditions of a rule, Launch will control the execution of the other Trigger (the DCR Rule) to be completed before continuing onward within the current Trigger.

Answers (2)

Answers (2)

Avatar

Avatar

thomas_amsler

Avatar

thomas_amsler

thomas_amsler

15-05-2019

You could also provide the required data as a payload with the tracking call, to be sure to have its data available.

If you empty digitalData anyway at the end, why do you even have it?

Avatar

Avatar

stefanm38281801

Avatar

stefanm38281801

stefanm38281801

10-05-2019

Hi,

from my understanding of how the direct call rule is replaced with an event capture rule in Launch, I suppose it is indeed running asynchronous.

So I suggest you move the clearing of your digitalData to an action event (custom script), after the action(s), where you process the rule.

Due to the action sequencing, in the order you set in the actions, you'll be sure that the data is cleared "after" processing.

Stefan