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

Send Beacon triggering twice: Success event & evars triggering twice

Avatar

Community Advisor

I have custom tracking done and when in the debugger I am testing that out my event is getting fired twice instantly. What could be the potential reason? I have the same configuration set up on one of our digital properties and I just duplicated the same on another digital property but saw the beacon firing twice.

 

What potential scenarios should I check?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I have resolved my issue by troubleshooting and testing. Here are my comments 

  1. I defined an event handler function to handle the event, then call the trigger(), and then remove itself by window.removeEventListener();
  2. After removing itself, I used a set timeout to re-add the event listener immediately via window.addEventListener(); This ensures that the event listener is re-added after the current event loop, allowing it to handle future events.
This approach ensures that the event is triggered only once per click and that the event listener is correctly re-added for subsequent clicks.

View solution in original post

3 Replies

Avatar

Community Advisor

Avatar

Level 1

<img src=1>

Avatar

Correct answer by
Community Advisor

I have resolved my issue by troubleshooting and testing. Here are my comments 

  1. I defined an event handler function to handle the event, then call the trigger(), and then remove itself by window.removeEventListener();
  2. After removing itself, I used a set timeout to re-add the event listener immediately via window.addEventListener(); This ensures that the event listener is re-added after the current event loop, allowing it to handle future events.
This approach ensures that the event is triggered only once per click and that the event listener is correctly re-added for subsequent clicks.