Search code examples
nuxt.jsnuxt3.js

Using both FB Pixel and GTM


Probably a simple question but, I want to use both GTM and FB Pixel.

The code below:

const { proxy } = useScriptMetaPixel({
  id: 'YOUR_ID'
})

  const { proxy } = useScriptGoogleTagManager({
    id: 'YOUR_ID'
  })

The issue I see is that both use PROXY from the deconstructor.

What would be the best practice to use both? I dont want to use the global option, as some pages should not use GTM and -or FB Pixel.


Solution

  • Try this:

    const { proxy: metaProxy } = useScriptMetaPixel({
      id: 'YOUR_ID'
    })
    
    const { proxy: googleProxy } = useScriptGoogleTagManager({
       id: 'YOUR_ID'
    })