Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.
SOLVED

Events Issue in WebSDK Implementation

Avatar

Level 3

Hello Experts,

 

I am facing one weired issue. This is regarding DOM Ready events that i am firing in WebSDK platform.

Suppose i have 3 different rules which are setting different Events. One is event1, Second rule is setting event2 and 3rd rule is setting event3.

 

Now when i send this data to Platform using Sendevent. What i see only the event which is part of Latest rule is there not the other 2. I am using Data Object for using Data Collection. Any help will be really appreciated.

 

Thanks,

Nitin

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @NitinCT 

that is actually a valid point, there is no apl plugin for Web SDK yet.

https://experienceleague.adobe.com/en/docs/analytics/implementation/vars/plugins/apl

bjoern__koth_0-1725880601730.png

 

But this doesn't keep us from using it At least not me.

What I typically do to counteract shortcomings and introduce new functionality is to extend the _satellite object in a rule that is loaded when the library loads.

 

bjoern__koth_2-1725880735616.png

 

and in there, I just copy+paste the code of the plugin.

 

bjoern__koth_3-1725880755781.png

Important: since it is an event at the end of the custom code, call

trigger();

 

and in the Web SDK update variable, you

content.__adobe = content.__adobe || { };
content.__adobe.analytics = content.__adobe.analytics || { };
let s = content.__adobe.analytics;

// add your new event
s.events = _satellite.apl(s.events, "event9999")

 

 

Cheers from Switzerland!


View solution in original post

9 Replies

Avatar

Community Advisor

Hi @NitinCT 

are you talking about the "events" variable in the data object e.g.?

data.__adobe.analytics.events = "event1";

 

When you look at the network traffic (filter for /ee), and expand your network requests, do you actually see your payload being set properly?

 

Cheers from Switzerland!


Avatar

Level 3

Hi @bjoern__koth ,

 

I am using the default variable Editor provided in Data Collection:

NitinCT_0-1725880081494.png

And Payload is loading properly(All eVars and Props from all rules are coming) only events is facing issue.

If i go with custom code route like 

data.__adobe.analytics.events = "event1";

Then do we have any function like s.apl to be used with WebSDK?

 

Thanks,

Nitin

Avatar

Correct answer by
Community Advisor

Hi @NitinCT 

that is actually a valid point, there is no apl plugin for Web SDK yet.

https://experienceleague.adobe.com/en/docs/analytics/implementation/vars/plugins/apl

bjoern__koth_0-1725880601730.png

 

But this doesn't keep us from using it At least not me.

What I typically do to counteract shortcomings and introduce new functionality is to extend the _satellite object in a rule that is loaded when the library loads.

 

bjoern__koth_2-1725880735616.png

 

and in there, I just copy+paste the code of the plugin.

 

bjoern__koth_3-1725880755781.png

Important: since it is an event at the end of the custom code, call

trigger();

 

and in the Web SDK update variable, you

content.__adobe = content.__adobe || { };
content.__adobe.analytics = content.__adobe.analytics || { };
let s = content.__adobe.analytics;

// add your new event
s.events = _satellite.apl(s.events, "event9999")

 

 

Cheers from Switzerland!


Avatar

Community Advisor

@bjoern__kothvery useful solution. loved it.

Avatar

Community Advisor

NOTE: for whatever reason I cannot edit my comment below

 

important that you check the commented code in the custom code block. it shows you how you can easily set props/eVars/events programmatically.

also note: you won't need to set linkTrackVars and linkTrackEvents anymore

Cheers from Switzerland!


Avatar

Level 3

@bjoern__koth I know what you provided works fine but my question is shouldnt' this be default behaviour? This works fine with existing s Object in our legacy implementation where we don't have to use apl function as well.

 

Just to simplify what i am asking here:

For simplifying the issue here:
1. I created Rule "Test 1" which sets event1 on Page Library load.

NitinCT_0-1725964992842.png

 


2. Rule 2 "Test 2" which sets event2 on Page Library load. [we do that when we need to fire event in specific scenario)

 

NitinCT_1-1725965026080.png

 


3. Rule 3 "Test 3" sends this data to Server.

 

Now Rule 3 should send both event1 and event2 together. But that is not happening only event2 is getting fired. Is this a defect or am i doing something wrong?

 

Thanks,

Nitin

Avatar

Community Advisor

Hi @NitinCT 

 

I am with you, this should not happen.

 

by any chance, have you checked the "clear existing value" checkbox and maybe that resets something?

bjoern__koth_0-1725966087822.png

 

Have you tried to log the events in the custom code sections?

 

content.__adobe = content.__adobe || { };
content.__adobe.analytics = content.__adobe.analytics || { };
let s = content.__adobe.analytics;

_satellite.logger.debug(">>> Analytics Events before", s.events);

// set your custom event with the code provided earlier
// ...

_satellite.logger.debug(">>> Analytics Events after", s.events);

 

would be interesting to know what this logs (make sure to have logging enabled with _satellite.setDebug(true); and all log levels active ("Verbose" has to be checked)

Cheers from Switzerland!


Avatar

Level 3

Hello @bjoern__koth I added below code in global rule

 

_satellite.apl = (lv,va,d1,d2,cc) =>{var b=lv,d=va,e=d1,c=d2,g=cc;if("-v"===b)return{plugin:"apl",version:"4.0"};var h=function(){if("undefined"!==typeof window.s_c_il)for(var k=0,b;k<window.s_c_il.length;k++)if(b=window.s_c_il[k],b._c&&"s_c"===b._c)return b}();"undefined"!==typeof h&&(h.contextData.apl="4.0");window.inList=window.inList||function(b,d,c,e){if("string"!==typeof d)return!1;if("string"===typeof b)b=b.split(c||",");else if("object"!==typeof b)return!1;c=0;for(a=b.length;c<a;c++)if(1==e&&d===b[c]||d.toLowerCase()===b[c].toLowerCase())return!0;return!1};if(!b||"string"===typeof b){if("string"!==typeof d||""===d)return b;e=e||",";c=c||e;1==c&&(c=e,g||(g=1));2==c&&1!=g&&(c=e);d=d.split(",");h=d.length;for(var f=0;f<h;f++)window.inList(b,d[f],e,g)||(b=b?b+c+d[f]:d[f])}return b};
trigger();

 

 

When i trigger apl function within custom code like below

content.__adobe = content.__adobe || { };
content.__adobe.analytics = content.__adobe.analytics || { };
let s = content.__adobe.analytics;

_satellite.logger.debug(">>> Analytics Events before", s.events);
// add your new event
s.events = _satellite.apl(s.events, "event9");
_satellite.logger.debug(">>> Analytics Events after", s.events);

 

I get TypeError: _satellite.apl is not a function

 

Not able to understand what is wrong here. Any suggestions you can share?

 

 

Avatar

Community Advisor

what do you see if you execute this in the console?

 

_satellite.apl

 

?

 

And when do you define the function? Is that rule fired on library loaded? 

Cheers from Switzerland!