Closed daneFFW closed 4 months ago
That demo is pretty old running the now dead google analytics v3.
Try with the latest version of Google analytics (totally different product sigh)
Actually, https://unpkg.com/@analytics/google-analytics/dist/@analytics/google-analytics.min.js is new GA4.
Demo is outdated. Try the below code
<script src="https://unpkg.com/analytics/dist/analytics.min.js"></script>
<script src="https://unpkg.com/@analytics/google-analytics/dist/@analytics/google-analytics.min.js"></script>
<script type="text/javascript">
/* Initialize analytics */
var Analytics = _analytics.init({
app: 'analytics-html-demo',
debug: true,
plugins: [
// attach google analytics plugin
analyticsGa({
measurementIds: ['G-abc123']
})
// ... add any other third party analytics plugins
]
})
/* Fire page view */
Analytics.page()
/* Attaching a listener */
Analytics.on('*', ({ payload }) => {
console.log(`Event ${payload.type}`, payload)
})
</script>
@DavidWells Thanks!! Ill check it outl.
I tried using the HTML demo here https://analytics-html-example.netlify.app/ but get errors in the console
(index):57 Uncaught TypeError: Cannot read properties of undefined (reading 'page') at pageView ((index):57:18) at HTMLButtonElement.onclick ((index):40:34)
I am also getting similar errors on my test site running the html version. https://verceltest-iota-jet.vercel.app/index-DW.html