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'
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);
'link_text': linkText || undefined,
'link_url': link_url || undefined
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.
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.
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.
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.
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