Answer the question
In order to leave comments, you need to log in
How to send a gtm vue event?
I need to submit a target like this on successful completion of a form in Vue
gtag('event', 'send', {
'event_category': 'forms'
}); return true;
<script async src="https://www.googletagmanager.com/gtag/js?id=GA-TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA-TRACKING_ID');
</script>
Answer the question
In order to leave comments, you need to log in
Create a variable in the windows object with a handler function pointer like this: mounted() {
window.vuehookfunction = this.someMethod.bind(this);
}
And then call in gtag:
gtag() {... window.vuehookfunction && window.vuehookfunction(params) ;}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question