WebSDK Update Variables - scope of 'this' | Community
Skip to main content
Level 2
Sep 11, 2024 7:40 AM UTC
Question

WebSDK Update Variables - scope of 'this'

Hi there,

 

We're working through a WebSDK migration at the moment and I have a question about 'this' scope in Update Variables

 

In old AA:

If I have a rule that fires on clicking something, in AA Update Variables Custom Code the 'this' object references the clicked HTML element.

 

In WebSDK:

Same rule, WebSDK Update Variables Custom Code, the 'this' now is the entire window object.

 

Does anyone have a way to get the clicked HTML element that fired the rule?

 

Side question is there any documentation around which javascript objects/function/etc the Web SDK Ext has access to?

 

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

kautuk_sahni
Employee
Oct 18, 2024 1:12 PM UTC

@paulbr15 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Translate
Kautuk Sahni
RiteshY18
New Participant
Sep 17, 2024 8:30 PM UTC

Please see below, hope it will address your event requirement @paulbr15 

 

https://experienceleague.adobe.com/en/docs/experience-platform/web-sdk/commands/configure/clickcollection

Translate
PaulBr15Author
Level 2
Sep 16, 2024 1:24 AM UTC

Update:

After some research, we can access the clicked element with the 'event' object. For reference the 'event' object is part of the Core Extension and is populated in every rule.

 

a console.log(event) outputs something like the below screenshot

 

 

Translate