Looking for a working example of how to create a profile script from a click event on a button | Community
Skip to main content
June 3, 2025
Question

Looking for a working example of how to create a profile script from a click event on a button

  • June 3, 2025
  • 1 reply
  • 360 views

I am looking for a working example of how to create a profile script from a click event on a button.

 

Please feel free to just post a working example of a working/functioning trackEvent() click event that someone has created which sends to parameters to the target-global-mbox and is used to create a profile script.

 

I followed the logic from the Experience League Documentation article and this Experience League question and used information from my site but nothing has worked so far. I added the onclick event to my button, and created the profile script as shown but I have had no luck, even making small changes to see if it helps. This is why I would prefer to see if anyone (fee free to use dummy data or code) has a working example of how to do this. Thank you!!

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

1 reply

NarenKotipalli
Level 3
June 4, 2025

@bkrane2 Try the snippet below, it adds a click event listener to all anchor (<a>) tags within Target offers:

 

document.querySelectorAll('.at-element-marker a').forEach(anchor => { anchor.addEventListener('click', () => { adobe.target.trackEvent({ mbox: "mbox-cta-click", params: { ctaSource: "${offer.id}" } }); }); });

Then, use the following profile script to set the profile attribute:

 

if(mbox.name == "mbox-cta-click" && mbox.param('ctaSource') == "1551876"){ return "true" }


Hope this helps resolve the issue.