UNPKG

gtm-vue

Version:

Wrapper for using Google Tag Manager with Vue. Inspired by vue-gtm.

15 lines (11 loc) 374 B
import {DirectiveOptions, VueConstructor} from 'vue'; export function setupDirective (Vue: VueConstructor, directiveName: string) { const trackDirective: DirectiveOptions = { bind (el, binding) { el.addEventListener('click', () => { Vue.gtm.trackEvent(binding.value); }); }, }; Vue.directive(directiveName || 'track', trackDirective); }