nuxt / modules

Discover the Nuxt modules to add any CMS, Database, UI, Auth and integrations into your Vue application.
https://nuxt.com/modules
MIT License
921 stars 250 forks source link

[Module Listing Request]: `gtag` #939

Open DamianGlowala opened 4 months ago

DamianGlowala commented 4 months ago

Description

This module provides Google Tag integration.

Repository

https://github.com/johannschopplich/nuxt-gtag

npm

https://www.npmjs.com/package/nuxt-gtag

Nuxt Compatibility

Nuxt 3

johannschopplich commented 4 months ago

@DamianGlowala Thanks a lot! Your preparation steps (and PRs) are amazing.

atinux commented 4 months ago

I would love to see the difference or how we can find a way to collaborate with the upcoming https://scripts.nuxt.com/scripts/tracking/google-tag-manager

As I never used GTag, your feedback is welcome 😊

johannschopplich commented 4 months ago

Great question!

Technically, a Google Tag ID is different from a Google Tag Manager. They are primarily used for analytics. While they can be embedded in the Google Tag Manager, the latter contains much more JS, which may be too much for simple analytics purposes.

Nuxt Gtag provides fine-grained options for working with multiple Google Tag IDs (for example, in admin panels where the preferred ID is only known after login), shortcuts like enableAnalytics, composables like useTrackEvent, and GDPR-related options.

It's a more opiniated approach than a generic useGoogleTagManager composable. That's why I'm not sure if it fits into the Nuxt Scripts approach. 🤔

danielroe commented 4 months ago

I think we'd love to see this here. It's a solid module and you're a good maintainer. But I want to be cautious about adding a community plugin in the days immediately before we launch Nuxt Scripts, particularly if this is something Nuxt Scripts will end up doing out of the box. Mostly, because it would be annoying for you. (If it's something that will add to what Nuxt Scripts does, then that's great!)

Might be worth putting on pause until Nuxt Scripts is released, at least.

cc: @harlan-zw

johannschopplich commented 4 months ago

Sounds like a good plan. Let's wait for Nuxt Scripts. Maybe I can then write a migration path for Nuxt Gtag users.

harlan-zw commented 4 months ago

This is a fantastic module and has captured a lot of the issues that Nuxt Scripts has also tried to solve for all scripts.

I think there could be scope for this module to exist with Nuxt Scripts but it would need to solve some GA specific DX issues that Nuxt Scripts isn't already solving. Some of which it is already doing:

The APIs for nuxt/scripts (you should already have access) are pretty much complete with just documentation and testing remaining, any feedback you have in terms of how it and this module can work together would be appreciated.

Would be especially interested to hear your thoughts on your module building on top of the Nuxt Scripts useScriptGoogleAnalytics() composable.