Skip to main content
All CollectionsTracking leads2) Tracking form submissions
Guide: How to track leads coming from form submissions with Google Tag Manager
Guide: How to track leads coming from form submissions with Google Tag Manager

In this guide, you will learn how to use special customizations on GTM if the standard SalesWings GTM Template does not pick up your forms.

Salah from SalesWings avatar
Written by Salah from SalesWings
Updated over 3 months ago

How to implement special customizations with GTM ?

If form tracking doesn’t work with the standard SalesWings template in GTM, we recommend that you create a form submission handler in GTM and then use this handler to send form-submission events.

  1. Go to the GTM workspace

  2. Create a new Tag

  3. Click on Tag configuration

  4. Choose Custom HTML

5. Add the following JavaScript snippet:

<script>
var emailElement = document.getElementById("XXX");
if (emailElement) {
var email = emailElement.value;
if (email) {
sw("send-form-submit", {
email: email
});
}
}
</script>

6. Replace “XXX” with the identifier of the email-address field of the form in question. The identifier can be any one of the following:

  • field id

  • field name

  • CSS selector etc.

In addition to the method getElementById you can also use other Document methods such as querySelector, etc.

How to find the attribute-name of the email-address field ?

  • Go to your website

  • Open the page where the form that you want to track is located

  • Open Developer Tools

  • Inspect the relevant email field

  • Copy the name of the attribute

6. Go to Triggering

7. Choose Form Submission trigger as a type

8. Save your tag

9. Don’t forget to Submit all your changes

Did this answer your question?