Expand my Community achievements bar.

SOLVED

Writing direct call function as custom code in Adobe Launch rule

Avatar

Level 1

Hi,

I have a data layer where data is pushed when an event occurs. Normally, I use Direct Call with the name of the event to fire the rule. However, I would like to have several event-names.

I know that it's possible to use several Direct Call's, however, I think it becomes too messy for my purposes here and therefore want to use custom code.

In another forum, I was adviced to use _satellite.track('yourstringgoeshere') in custom code. Although, I am not able to fire the rule by doing this. I am passing the event name as 'yourstringgoeshere'. Is this the right way to do it? Is there anything else I need to do?

Note: Under actions I am using Set Variables and Send Beacon with s.tl().

My previous question was posted here: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-platform/writing-direct-call-funct... 

Can anyone help me? Thanks in advance!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

No, what I'm suggesting is for your Rule to contain 1 Event and 1 Condition, like so:

yuhuisg_0-1669109575931.png

yuhuisg_3-1669109643255.png

yuhuisg_2-1669109623795.png

Then, in your website code that calls the Direct Call, you use something like this:

var detail = {
  flag: "some value for situation 1",
};
_satellite.track("yourstringgoeshere", detail);

Then, you can replicate all of the above for any other situations that you have, replacing the website code's "flag" line and the Value Comparison condition accordingly.

 


- What should i put in "yourstringgoeshere"?

I got this from your original post. I assume that you know the actual Direct Call identifier that you should use there.

View solution in original post

7 Replies

Avatar

Community Advisor

Instead of using multiple Direct Calls, you can still use one Direct Call, but include a "details" payload that has something to identify your different situations.

i.e.

var detail = {
  flag: "some value for situation 1",
};
_satellite.track("yourstringgoeshere", detail);

Now, in your "situation 1" rule, use this Direct Call, and add a Value Comparison condition:

%event.detail.flag% equals "some value for situation 1". Your rule will now run only for situation 1 and no other situations.

Do the same for your other situations.

Hope that helps!

Avatar

Level 1

@yuhuisg , thanks for your reply!

 

I am not sure I understand completely:

In a rule, under events, I put 2 events: 1 Direct Call and 1 Custom code.

 

In Direct call I can put %event.detail.flag%.

In Custom Code:

- How should I write the value (event name from datalayer) for situation 2?

- What should i put in "yourstringgoeshere"?

 

Thanks again!!

Avatar

Correct answer by
Community Advisor

No, what I'm suggesting is for your Rule to contain 1 Event and 1 Condition, like so:

yuhuisg_0-1669109575931.png

yuhuisg_3-1669109643255.png

yuhuisg_2-1669109623795.png

Then, in your website code that calls the Direct Call, you use something like this:

var detail = {
  flag: "some value for situation 1",
};
_satellite.track("yourstringgoeshere", detail);

Then, you can replicate all of the above for any other situations that you have, replacing the website code's "flag" line and the Value Comparison condition accordingly.

 


- What should i put in "yourstringgoeshere"?

I got this from your original post. I assume that you know the actual Direct Call identifier that you should use there.

Avatar

Level 1

I'm not seeing how this code improves the process if you just use a direct call function with the unique trigger name to trigger on.

How is this any different than just having the flag value be the direct call function trigger name? Why is the conditional needed for using flag, what does that gain you unless you are using the same direct call function name and need to differentiate between the two?  From a developer standpoint I don't see the gain?

Avatar

Community Advisor

@MichaelG wrote:

Why is the conditional needed for using flag, what does that gain you unless you are using the same direct call function name and need to differentiate between the two?

That is indeed what I had stated in my first reply: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-platform-data/writing-direct-call-...


Instead of using multiple Direct Calls, you can still use one Direct Call, but include a "details" payload that has something to identify your different situations.


I had assumed from the original post that that was what was wanted: a way to reduce the number of Direct Call identifiers. Programmatically, it could be easier to set a flag value (which could also be of different types), rather than having multiple unique Direct Call identifiers.

Avatar

Level 1

Basically he is saying that use one direct call identifier and use event detail uniquely for the diff scenarios. 
This doesn't make sense to the asked question. You still have to update diff rules and within those rules, event details values as well. 
This still remains unanswered that that lets say there are diff direct calls and we want a custom code to consolidate all the direct calls into one single rule/events. How to do so?