- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
05-25-2018 03:45 AM
document.getElementById('EditcontactPage').addEventListener('click',clickListenerFunction); function clickListenerFunction() { var data={ "event_parent" : "Page Tag", "event_type" : "Click", "event_id": "EditcontactPage", "event_value" : "http://localhost:4200/editcontact", }; console.log("data", data); utag.link(data); };`
Solved! Go to Solution.
05-25-2018 05:31 AM
Hi @sujay_das - the only issue I notice with the code itself is an extra comma:
Are you adding that code via a 'DOM Ready' scoped TiQ extension? If not, give that a try - other scopes could easily result in that code firing multiple times (adding multiple listeners) in different scenarios, which could lead to the symptoms you've described.
If that doesn't work, I'd suggest giving the Community some more information about where we can see the issue / your specific implementation.
Hope that helps!
05-25-2018 05:56 AM
05-25-2018 08:22 AM - last edited on 05-28-2018 09:26 AM by kathleen_jo
What is the scope of the extension with the code, @sujay_das? If this code runs a second time (ie within the utag.link call) then it will add a second handler to the element.
If you add a breakpoint to the first line in the Chrome Debugger you should see if it is running twice. If that's the problem, you can either change the scope to one of the "Run Once..." options, or you could wrap the whole thing in a condition to stop it firing a second time.
06-06-2018 12:20 AM
06-06-2018 02:02 AM
Hi @sujay_das,
I usually use DOM Ready, because it's important that the HTML element you're adding the listener to is already present (and DOM Ready ensures that, assuming a standard HTML page).
The other 'Run Once' options that @BenStephenson mentioned will probably work just as well, since it's very unlikely that setting would result in trying to add the listener before the element is present. I'd expect either approach to work fine in most cases.
06-06-2018 08:28 AM
07-13-2020 04:49 AM
I am also facing a similar kind of issue when I place this code in the Tealium with scope DOM ready function is called multiple times.
window.tealium_sourcepoint = function(e) {
if (e.origin.toLowerCase() === 'https://notice.sp-prod.net') {
e.stopPropagation();
e.bubbles = false;
console.log(e.data)}}
window.addEventListener('message', tealium_sourcepoint, false);
Copyright All Rights Reserved © 2008-2023