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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Custom code in "Set Variable" section executing asynchronously

rupaljain2408
Level 3
Level 3

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.

1 Accepted Solution
gflare
Correct answer by
Level 4
Level 4

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.

View solution in original post

4 Replies
stefanm38281801
Level 4
Level 4

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

thomas_amsler
Level 9
Level 9

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?

gflare
Correct answer by
Level 4
Level 4

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.

View solution in original post

jantzen_belliston-Adobe
Community Manager
Community Manager
Do any of the answers below answer your initial question? If so, can you select one of them as the correct answer? If none of the answers already provided answer your question, can you provide additional information to better help the community solve your question?