Hi ๐
First, thanks a lot for building and maintaining nuxt-meta-pixel โ itโs very helpful for integrating Facebook Pixel with Nuxt.
I ran into a limitation with the current design:
The module only supports configuration via runtimeConfig.public.metapixel or ENV variables.
In our use case, each store (or tenant) has its own Pixel IDs stored in a database.
When a user visits a store, we fetch its settings (including pixel.ids) from an API and only then know which Pixel(s) to initialize.
Currently, because the IDs must be known at build/runtime, thereโs no way to dynamically initialize the Pixel after fetching settings.
Suggested Solution
It would be great if the module exposed an API to manually initialize pixels after fetching data.
For example:
const { $fbq, initPixel } = useNuxtApp()
await settingsStore.fetchSettings()
initPixel(settings.pixel.ids, {
advancedMatching: { em: 'user@example.com' },
autoConfig: true
})
// From now on we can use $fbq('track', 'PageView') or the helpers
```ts
This would let us:
Keep all the nice features ($fbq, helpers, PageView integration, script injection, etc.)
But still support dynamic initialization after API calls instead of being locked to runtimeConfig.
---
Why is this useful?
Not just for multi-tenant setups โ also for any project where pixel configuration is managed in a CMS, database, or admin panel.
Keeps runtime flexibility without needing separate deployments per pixel ID.
---
Alternatives Considered
Implementing our own plugin that loads the meta-pixel library directly and re-implements $fbq, but then we lose the benefits of this Nuxt module.
---
Would you consider adding this kind of API? Iโd be happy to help test or contribute if needed.
Thanks again ๐
Hi ๐
First, thanks a lot for building and maintaining nuxt-meta-pixel โ itโs very helpful for integrating Facebook Pixel with Nuxt.
I ran into a limitation with the current design:
The module only supports configuration via runtimeConfig.public.metapixel or ENV variables.
In our use case, each store (or tenant) has its own Pixel IDs stored in a database.
When a user visits a store, we fetch its settings (including pixel.ids) from an API and only then know which Pixel(s) to initialize.
Currently, because the IDs must be known at build/runtime, thereโs no way to dynamically initialize the Pixel after fetching settings.
Suggested Solution
It would be great if the module exposed an API to manually initialize pixels after fetching data.
For example: