Web SDK Click Tracking - referencing 'this' object?
Hey all,
I'm back with another question that I'm hoping you might be able to help me with. I'm trying to figure out away to reference the javascript 'this' object while writing code within the Web SDK Extension's "On before link click send callback" custom code screen.
If I add a console log for the 'this' object while in a click rule (based on a CSS selector), I get a valid response
custom code used in my click rule:
console.log("nav click rule: this.href");
console.log( this.href );
Response I get in my console for this click rule:
nav click rule: this.href
https://www.blueacornici.com/Commerce/
So that works, when I'm working in the rule.
But if I try the same thing when I'm working in the "On before link click send callback" custom code screen, I get an error message.
The custom code i used:
console.log( "checking for link this.href" );
console.log(JSON.stringify( this.href, null, 4 ));
my results
checking for link this.href
undefined
So it appears the 'this' object is not available when working in the "On before link click send callback" custom code screen, but again it is available when working within a rule triggered by a css selector click.
Does anyone have any ideas on how to reference the details of what the user clicked on while working in this section of the Web SDK? please provide specific code example so I can try to backwards engineer a solution. Thanks!
follow up on 02-27-2024
per the documentation, there is supposed to be an object called 'clickedElement' when using this click callback back solution. https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/configuring-the-sdk.html?lang=en
but when I try to console log for that element, I get another error message saying it doesn't exist.
Not sure what I'm missing here?!
