Ohe function to solve all problems
by Victor Osório
HTML
<button google-tag="1">BTN 1</button>
<button google-tag="2">BTN 2</button>
<button google-tag="3">BTN 3</button>
<button google-tag="4">BTN 4</button>
<button google-tag="5">BTN 5</button>
<button google-tag="6">BTN 6</button>
JavaScript
var buttons = document.querySelectorAll("[google-tag]");
buttons.forEach(button =>
button.addEventListener('click', event =>
alert(event.type + ": x=" + event.x + " y=" + event.y + "\nTAG: " + button.getAttribute('google-tag'))));