简体   繁体   中英

How to get custom events in GA4

My website is static pages.

Using this gtag.js:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-measurementid"></script>
<script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-measurementid'); </script>

Under Admin I turned off the Enhanced Measurement setting "File Downloads" to allow for my custom event.

Using this event handler:

<a href="./special.pdf" onclick="ga('send', 'event', 'cw-downloads', 'cw-download-pdf', 'special.pdf',);">Print this page </a>

But at analytics.google.com my custom event doesn't show. Both Realtime and in next day's report.

You can use this syntax:

gtag('event', 'login', {
  'method': 'Google'
});

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

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