Tag Firing Twice | Community
Skip to main content
Level 2
March 22, 2023
Solved

Tag Firing Twice

  • March 22, 2023
  • 1 reply
  • 1986 views

Hi all, I'm at my wit's end trying to figure out why a relatively simple tag is firing twice on the page. It's a gtag (google analytics tag) that fires on click of an anchor element with the telephone attribute. (see pictures below)

This is the script inside of the action 'Tag: GA4 telephone_click event'

try{
var e = this;
let linkText = e.innerText.trim();

let href = e.closest('a').href;

const regex = new RegExp('tel:*')
//capture the url by getting everything AFTER the 'tel:'
const link_url = href.substring(href.indexOf(':') + 1);


if(regex.test(href)){
gtag('event','telephone_click', {
'link_text': linkText || undefined,
'link_url': link_url || undefined
});
}
}
catch(e){
satellite.logger.error('[GA4] telephone_click error: ',e);
}

When I check the network requests and data layer however.. I see the 'telephone_click' event two times. I don't know why this is happening. I'm also including a picture of the html code for an example of an item I'd be clicking.

 


After just one click this is how the network request tab looks

Any advice or suggestions is very much appreciated. I tried Googling and looking at previous questions in addition to unchecking 'Allow this rule to run even if the event already triggered a rule targeting a descendant element' in the advanced options of the event.

Thank you!

 

 

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 yuhuisg

Unfortunately this was not the issue but thanks for the suggestion. (I think your answer has been automatically accepted as the correct answer by Adobe's algorithm since no other answers have been made.)


Try logging your "this" object to see what element it's referencing. Hopefully, that gives a clue about what elements the browser is detecting when the user clicks your tel: link.

var e = this; console.log('this object', e); // rest of your code

1 reply

yuhuisg
Community Advisor
Community Advisor
March 23, 2023

Does your GA4 property have the Enhanced Measurement tracking enabled? Ref: https://support.google.com/analytics/answer/9216061?hl=en This allows for some user actions to be tracked automatically. If you have it enabled, then I wonder if that's causing the 2nd hit, which would then have nothing to do with your implementation.

aksumAuthor
Level 2
March 23, 2023

Hi thanks for the response. Yes, I believe the GA4 property has enhanced measurement tracking allowed but I don't think this is the problem since other tags work just fine in the same property.

yuhuisg
Community Advisor
Community Advisor
March 24, 2023

To eliminate this Enhanced Measurement as the cause, I suggest disabling it in your GA4 property setting, wait a while (to allow GA to update its script), then load your website (preferably in a private window, so that you don't have to deal with previous cache and cookies), then test your tel: link click to see if you still get the double tracking.