Skip to content

asyncID with multiple id does not seem to work #117

@owalid

Description

@owalid

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
  })
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions