nuxt-community/google-analytics-module

asyncID with multiple id does not seem to work

owalid opened this issue · 2 comments

Hello

I would like to add a google analytics from my store. I use asyncID. This code works well in dev but in production I have only the first id which is static. My store is init at the nuxtServerInit level

Am I doing something wrong?

nuxt.config.js:

....

 buildModules: [
  ....
    '@nuxtjs/google-analytics'
  ....
  ],

googleAnalytics: {
    checkDuplicatedScript: true,
    autoTracking: {
      screenview: true
    },
    debug: {
      enabled: process.env.NODE_ENV === "developpement",
      sendHitTask: process.env.NODE_ENV !== "developpement"
    },
    asyncID: (context) => {
      const stats = context.store.getters['shop/getShopStats']

      return (stats && stats.google_analytics_account) ? ['UA-xxxx-xxx' stats.google_analytics_account] : ['UA-xxxx-x']
    }
  },


 plugins: [
  ....
    '~/plugins/client/gtag.client',
  ....
  ],

gtag.client.js:

export default ({ app }) => {
  app.$ga.page({
    page: '/',
    title: 'Home page',
    location: window.location.href
  })
}

same here I can not use multiple ids

HI! I will need to use multiple id to... Is it resolved?