GA4 Analytics Track Click Event And Check If Working

- 1 answer

I have my tracking code here already in the site:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-XXXXXXXXX-X');

I am using these event ga('send', 'event', 'Link', 'Click', 'Purchase Details'); but every time I clicked on the link, it does not capture anything. Am I doing this wrong or are the event tags needed to be setup first in GA?

this is my onclick code:

<li><a href="#" onclick="ga('send', 'event', 'Link', 'Click', 'LinkedIn Redirect');"><i class="fab fa-linkedin-in fa-lg"></i></a></li>


You're debugging it incorrectly. It takes up to two days for GA to populate the events.

Either use Real time data in GA, or even closer to the click - use the Network tab in your dev tools.