Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML integration does not recognize Analytics.page analytics.track #431

Closed
daneFFW opened this issue Apr 26, 2024 · 3 comments
Closed

HTML integration does not recognize Analytics.page analytics.track #431

daneFFW opened this issue Apr 26, 2024 · 3 comments

Comments

@daneFFW
Copy link

daneFFW commented Apr 26, 2024

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)

24-04-26-1053

I am also getting similar errors on my test site running the html version.
https://verceltest-iota-jet.vercel.app/index-DW.html

24-04-26-1055

@DavidWells
Copy link
Owner

That demo is pretty old running the now dead google analytics v3.

Try with the latest version of Google analytics (totally different product sigh)

@DavidWells
Copy link
Owner

DavidWells commented Apr 30, 2024

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>

@daneFFW
Copy link
Author

daneFFW commented May 14, 2024

@DavidWells Thanks!! Ill check it outl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants