2

I want to track form submissions on the website in Google analytics. I was considering to add the following code to the SUBMIT button,

<input id=”contact-submit” class=”button” type=”submit” value=”Submit” onClick="ga('send', 'event', { eventCategory: 'requestinfo', eventAction: 'submit', eventLabel: 'undergrad'});">

But can I do all of this through Google tag Manager to improve efficiency?

2

There are many ways so it really depends on what you are trying to accomplish. Below are a few options that will work on contact forms and any other type of click action.

1) You can setup a link trigger in GTM with HTML5 data parameter and class or ID

<input id=”contact-submit” class=”button” type=”submit” value=”Submit" data-form="Contact Us" data-whichpage="Home Page">

In GTM, fire on gtm.linkClick and use element ID -> equals -> contact-submit

2) If you have a confirmation page you can setup a dataLayer and use custom dimension to capture the information.

On your confirmation page setup a data layer using PHP or something:

dataLayer.push({
"Form_Name": "Home Page",
"Form_Type": "Contact Us",
"Custom_Dimention_2": "Parameter 2"
});

Then in GA create the custom dimentions and match them up with corresponding fields in GTM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.