Vue Tag Manager
Simple Google Tag Manager implementation for Vue
// Do this before creating the Vue appVue...
Later in app:
Vuegtm// or in a componentthis$gtm
or in a template:
||Google Tag Manager ID||
||Additional parameters to add to the script URL, including
||Initialise the GTM datalayer with variables.||
||The Data Layer variable name||
const entry = event: 'something'this$gtm// orVuegtm
On a TagManager instance, this method allows you to push events onto the initialised data layer. See the Google Tag Manager documentation for more details on event tracking with GTM.
<!-- In code later -->
- Initital implementation from React GTM
- Basic Vue Plugin
- Shell out tests
- Simplify the URL + snippet generation and injection
- Vue prototype property
- Basic implementation - don't break on SSR
- Vue auto-track router
- Vue track directive
- More through docs with examples
- SSR support
Why need another GTM library?
Initially used vue-gtm which is a great library, but wanted to be able to programatically configure the GTMID and initial DataLayer.
Really liked the React GTM script injection dev experience, and liked the Vue GTM dev and track experience (as a Vue Plugin, with the
$gtm interface). So this plugin aims to combine both of them into this simple library.