How to pass Marketo form submissions through GTM & into GA4

It took me several months to finally figure out how to successfully pass specific Marketo form submissions into Google Tag Manager, and then pass those custom events into Google Analytics 4. It was quite a journey!

Step 1. Google Tag Manager: Add a Marketo event listener

You'll find different variations of this code online, but after speaking with two extraordinarily smart developers*, I landed on the following code — you can grab it from the PasteBin link below or contact me.

https://pastebin.com/1crVngC6

Now that you have your 95 lines of custom code (thanks Marketo 🙄), head over to Google Tag Manager.

  1. Create a new tag; call it something like: Forms – Marketo Event Listener
  2. Tag type: Custom HTML
  3. Paste in the 95 lines of Javascript code
  4. The trigger for your tag could be "All Pages" — however, I went with "Window Loaded" to ensure that all page elements (especially our Marketo form) load fully before this event listener goes into effect.

Step 2. Google Tag Manager: Create a user-defined variable

  1. Click on "Variables" in the left-hand menu
  2. Scroll down to "User-Defined Variables" and click "New"
  3. Name it Marketo Form ID
  4. Variable Configuration > Variable Type: Data Layer Variable
  5. Data Layer Variable name: mkto.form.id
  6. Data Layer Version: Version 2
  7. Save (the "references to this variable" will come later).

Step 3. Google Tag Manager: Create tags and triggers

Let's do the following for each individual Marketo form you want to track:

Create a new tag

  1. Name it something like: GA4-newsletter
  2. Tag type: Google Analytics GA4 Event
  3. Event name: This is what will eventually appear in GA4. You can name it whatever you like; underscores are recommended. I've often used: newsletter_form_submit
  4. Associate this tag with the trigger you'll create below...

Create a new trigger

  1. Name it something like: Marketo #### submit newsletter
  2. Trigger type: Custom Event
  3. Event name: mkto.form.success
  4. This trigger fires on "Some Custom Events"
  5. Fire this trigger when an Event occurs and all of these conditions are true: "Marketo Form ID" (this is the variable you created earlier) "contains" "####" (this is where you'll need at least part of the Marketo form ID. In my case, it was a series of four digits.

Test your tag in Preview Mode

This could be an entirely separate blog post, so if you need guidance here, Google is your friend. Verify that your new tag(s) are indeed firing correctly in GTM Debug/Preview mode, and remember to publish your GTM instance live.

Once I verified my tags were firing correctly — that's when things got interesting, aka frustrating.

🫡🙏

*Before I go any further, I'd like to give a big thank you to those two fantastic developers I mentioned earlier. Each volunteered significant time and helped me diagnose various issues throughout this process, including the GA4 conundrums I'll dive into next. Thank you to:

  • Michael Query, founding engineer, adMind Analytics — I was blown away by Michael's knowledge in all things analytics and code. He is highly impressive!
  • Sanford Whiteman of Teknkl — he knows just about everything about Marketo.

Step 4. Fill out your Marketo forms on your live site

This is required, so that the form fills actually fire in GTM, and then can pass into GA4. Be patient here — it can take 24-48 hours for those custom events to finally show up in GA4. Also remember to do this in incognito or VPN, if you are blocking your own IP address in GA4.

Step 5. Go to Google Analytics 4

Go to Admin > Events. If your new custom events (your Marketo form submissions) aren't showing up here after a couple days, there are a couple things you can do.

First, go to Reports > Engagement > Events, as per the screenshot below. Look for the dreaded orange triangle with the exclamation mark — this is a "data thresholding" warning. Data thresholding was likely the root cause of why I did not see my custom events in GA4 appear for weeks.

I went back and forth with Google about this — you can contact Google Support here, and you don't have to be a paid ads customer. I asked them about GA4 data thresholding, why is it being applied, etc. (I've never seen it as an issue in more than a dozen other GA4 accounts)

Google support wrote in an email verbatim:

Unfortunately, there isn’t a clear clarity on what will trigger Google’s data thresholds or the required minimum aggregation thresholds as this is system defined, and we can't adjust them.

Thanks, Google 🙄.

When data thresholding is being applied, you may notice that your custom events are being logged in certain GA4 views/timeframes (see the right side of the graph above), yet those event counts aren't consistent in other GA4 screens/reports. Here's how to correct that issue (which I consider to be a GA4 bug).

Step 6. Fix the GA4 data thresholding problem

  1. GA4 > Admin > Reporting Identity > Click "Show All" (this is fairly hidden, but it's there on the lower right)
  2. Change from Blended or Observed to device only, aka Device Based. Learn more about these reporting identities and their ramifications here.

If you're still having issues 24 hours after modifying your reporting identity settings, one final thing you can try is: Go to GA4 > Admin > Data Settings > Data Collection, and turn OFF Google Signals.

Conclusion

This was a two-pronged issue that took me many weeks to work through. Neither Marketo nor GA4 are user-friendly when it comes to measuring form submissions, and I hope they improve. Let me know what your experience has been like. Good luck!