0
votes

Why this simple event does not fire/appear

<a id="menu" href="a.html" onclick="gtag('event', 'navigation', 'menu');">A</a>

There is no error in browser js console or Google tag assistant tool, it shows PageLoads OK.

The Analytics Events appear OK in Google Analytics for other events, that are executed inside JS React Component like this:

  gtag("event", "game", {
    event_category: "Update"
  });
1
What happens if you click on that link? Are you redirected to another page? a.html in this case.Lajos Arpad
yes, link click works, but bug is that GA does not show event dataTom
Also a.html appears in GATom
It is possible that the redirect happens before the onclick. Can you tell me which browser are you testing it?Lajos Arpad
all browsers, thousands of usersTom

1 Answers

1
votes

The syntax used is not the same for the two examples:

gtag('event', 'navigation', 'menu');

should be:

gtag('event', 'menu', { event_category: 'navigation' });

https://developers.google.com/analytics/devguides/collection/gtagjs/events