Send Beacon triggering twice: Success event & evars triggering twice | Community
Skip to main content
JyotiSharmaV
Community Advisor
Community Advisor
September 25, 2024
Solved

Send Beacon triggering twice: Success event & evars triggering twice

  • September 25, 2024
  • 2 replies
  • 909 views

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?

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

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.

2 replies

JyotiSharmaV
Community Advisor
Community Advisor
September 25, 2024
September 27, 2024

<img src=1>

JyotiSharmaV
Community Advisor
JyotiSharmaVCommunity AdvisorAuthorAccepted solution
Community Advisor
September 26, 2024

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.