gtm

If you use Marketo Forms 2.0 then this documentation is critical for understanding how to track form submissions. This example specifically serves two important functions: first, it shows how to handle an onSubmit action, and second it shows how to grab the values from a form. Here’s the code from the example:

This code can be repurposed to “listen” for a Marketo form submission. To track this via Google Tag Manager, start by creating a custom HTML tag: select tags

Click the “New” button and select Custom HTML:

custom_html

If you are generating leads through a content strategy (KissMetrics generates a crazy amount of leads just through their blog) and you are using a Marketo form for lead generation then the code for the custom HTML tag might look something like this:

The next step is important: you need a trigger for this custom HTML tag to fire, ideally a trigger that will load the custom HTML when a page with a Marketo form loads. For example, if you have gated content (such as white papers) you’ll need to use a trigger that covers all those gated pages. It’s not a good idea to trigger this tag on every page, so try to trigger this script only when the Marketo form is actually present.

Now that you have a tag and a trigger to fire the custom HTML on page load, let’s walk through each line to better understand what’s going on:

For each of the new dataLayer variables you use (such as “marketoCompany” and “marketoLeadSource”), you’ll need to add those in the Variables section of Tag Manager:
variables

And select Data Layer Variable:
datalayer var

Now fill out the details for the variable:
make variable

Progress check: we have a new “listener” for forms that’s only triggered on pages where a forms exists. We have variables from the dataLayer. Next we’ll need a trigger and one more tag. The trigger listens for marketoFormSubmit event we created in the first tag:
trigger

Almost there…one last tag to setup!

The last thing we’ll need is to send this to the relevant tracking service. Since this is Tag Manager, we could send this to multiple services; the example below is for Google Analytics.

Go to Tags, select “New” and create a Google Analytics event tag (hopefully you are using Universal Analytics by now!). Select the “Event” track type and fill in the values as needed:
final tag

Of course, add the new trigger we just created. Test this out in Preview mode, and if everything works as expected, hit Publish.

Et voilà! You can track Marketo forms to your hearts content.

 

Read more