nuxt-community / google-analytics-module

Google Analytics Module for Nuxt 2
https://google-analytics.nuxtjs.org/
MIT License
638 stars 54 forks source link

Nuxt 3 GA4 timeline? #135

Closed safejace closed 1 year ago

safejace commented 2 years ago

hey,

just wondering if there is a roadmap for the nuxt3 module and if it will support GA4. i would be willing to help with testing/dev but i just don't know where to find any work on it

ermish commented 2 years ago

^ this library is failing in my nuxt 3 upgrade :(

silverbackdan commented 2 years ago

Looks like it should probably move over to using vue-gtag - this module doesn't look so complicated. If I get implemented I'll post here what I've done.

silverbackdan commented 2 years ago

Actually, for google analytics, there is a simple plugin example for implementing it here: https://v3.nuxtjs.org/guide/directory-structure/plugins/#vue-plugins - might be a useful way to get started. E.g.

import VueGtag from "vue-gtag";

export default defineNuxtPlugin((nuxtApp) => {
  const router = useRouter();
  nuxtApp.vueApp.use(
    VueGtag,
    {
      config: {
        id: "GA_MEASUREMENT_ID",
      },
    },
    router
  );
});

I think this is double tracking right now though and not sure if it's detecting page changes as views properly so needs some looking into.

ineshbose commented 2 years ago

I think the solution above is a brilliant place to get started if a PR could be opened with the same. I hope it doesn't take long because the main files seem to be plugin.js and module.js if I'm not wrong!

silverbackdan commented 2 years ago

Problem is that on first SSR load it doesn't track the right page title.

notflip commented 1 year ago

@silverbackdan Can I trust your code snippet to work? Did you have time to test this more? Thanks!

dapug commented 1 year ago

@silverbackdan Can I trust your code snippet to work? Did you have time to test this more? Thanks!

Didn't work for me.

silverbackdan commented 1 year ago

It worked at the time of posting however perhaps things have changed, sorry for this.

johannschopplich commented 1 year ago

Hey guys! I've created a seamless GA4 integration for Nuxt 3. 👉 github.com/johannschopplich/nuxt-gtag

Features

rutgerbakker95 commented 1 year ago

@johannschopplich awesome. I will try

harlan-zw commented 1 year ago

Will track here https://github.com/nuxt-community/google-analytics-module/issues/140 :)