Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards

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

Avatar

Level 1

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!!

1 Reply

Avatar

Level 3

@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.