Removing inline onclick event tracking code and putting it in an external file

Multi tool use
Multi tool use

The name of the picture


Removing inline onclick event tracking code and putting it in an external file



I have many tracking codes attached to link tags (onclick="") and these are scattered throughout my page and it looks very messy.



It looks like,


<a href="tel:+123456789" onclick="gtag('event', 'click', { 'event_category': 'Phone', 'event_label': 'Header phone link' });">+123456789</a>



I was wondering if they could all be removed and moved to an external js file to keep the page clean and readable. If so how do I do it?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Smx1phJho6a60UrgN AJrA
Ac 1TG0foujlzBCtf9x JZUUXYwr

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Makefile test if variable is not empty