Quantcast
Channel: Developers - Community
Viewing all articles
Browse latest Browse all 479

How to track form submission on Google Analytics

$
0
0

Hello there,

I use the thank you message after submissions on my forms but I'm not being able to track the submissions on GA. (I can't use a thank you page/URL to confirm this)

I've tried adding a script to send the event to GA but it didn't work (code below).

Also saw if there were any variables available to track this event on GTM, but it didn't too.

<script>
var activeForms = document.getElementsByClassName('_form_20');
var myForm = activeForms[0];

myForm.addEventListener("submit", function () {
console.log('The form was submitted');
ga('send', {
hitType: 'event',
eventCategory: 'Forms',
eventAction: 'Submit',
eventLabel: 'Modal Form'
});
});

</script>

Any suggestions on how can I track these conversions/form submissions on Google Analytics?

Any other solutions? Via GTM maybe?


Viewing all articles
Browse latest Browse all 479

Trending Articles