简体   繁体   中英

GA4 Analytics track click event and check if working

I have my tracking code here already in the site:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-XXXXXXXXX-X');
</script>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM