Ad
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>
Ad
Answer
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.
Ad
source: stackoverflow.com
Related Questions
- → Is access to the Google Analytics Realtime Reporting API (via javascript) handled similarly to the Core Reporting API or is it dramatically different?
- → How can I catch outbound link click on an Angular 1.x website?
- → How to recover my website page ranking, after using google analytics?
- → How to make onclick event works via Jquery
- → Does Google Analytics emit an event when they are set up?
- → GA / GTM Enhanced Ecommerce | Measuring Product & Product Details Impressions
- → Integrating GTM with Shopify
- → Liferay and Google Tag Manager implementation
- → Google Tag Manager - click on link with specific text
- → Hooking Javascript Onload for a specific JS file
- → Shopify - How to make google analytics load after page load?
- → how do I turn off google analytics while using angulartics
- → Fetch Google Analytics Data from Multiple Websites - Laravel
Ad