Tracking form-loads and form-submissions with google analytics events

Highlighted
Anonymous
Not applicable

Tracking form-loads and form-submissions with google analytics events

Hello all,

I've reviewed a good handful of posts regarding Incorporating Google analytics Events with Marketo actions but I'm struggling to find a solution I think could be helpful for many of us.

Some good posts on GA and Marketo I've reviewed so far, which I recommend:

But here is what I'm looking to do, and the above do not seem to clearly address or answer what I'm looking for:

I'd like to track and event for "Marketo Form Load" and then an event for "Marketo form submit" within google analytics to review our web conversion rates and establish GA goals& goal flows around our Marketo embedded forms.

My main question: Is there anybody currently doing this, or is there a better way/ reason I should stop exploring this implementation?

If it seems like a decent approach to the community, I need some support making it happen.

Below are some details on my scenario and how I'm trying to track this.


  • We utilize a global form with progressive profiling for all of our navigable web resources. (case studies white papers etc..)
    • A custom field "latest form fill page" is populated using JS in a Rich text object in the global form itself.
    • Depending on the value in this field users are directed to the pdf asset corresponding to their URL

Current tracking:

  • Webhook sent on completion (Marketo flow action) that tracks a google analytics event (see: Google Analytics and Marketo: Events and Forms and APIs, Oh My! )
    • Category: Form
      Action: Form Submitted
      Label: "latest form fill webpage" value (URL)
    • Downside: webhook will let me count the conversions, but it won't let me view any of the rich data that comes with the web sessions leading to that conversion

My goal:

  • send and event on form load
  • send an event on form submit

This will allow me to see all the data of the web sessions leading to that form completion and set up goal paths etc on GA.

here's the JS that runs in the global form Rich text.

<script>// <![CDATA[

MktoForms2.whenReady(function(form){

      form.addHiddenFields({"latestFormFillWebpagec":document.location.href});
     // populates the hidden field that is critical to sending users to the appropriate url/ .pdf

      ga('send', 'event', 'Form', 'Form Loaded');// I thought this would do the trick for tracking form-loads but GA isnt picking it up

})

// ]]>

</script>

Thanks in advance! I know this is complicated and extensive, but I think it could help a lot of folks!

6 REPLIES 6
Highlighted
Anonymous
Not applicable

Re: Tracking form-loads and form-submissions with google analytics events

Are you asking if this is a good idea (yes, it certainly seems to have application for conversion tracking) and/or are you asking for help with the code at the bottom of the page (with the comment that it is not sending the event)?

Highlighted
Anonymous
Not applicable

Re: Tracking form-loads and form-submissions with google analytics events

Thanks Jason,

1. Yes, I'm looking for some affirmation. Not finding the answers already had me feeling like I was missing something.

2. Yes, I'm looking for support with the code as well.

Highlighted
Anonymous
Not applicable

Re: Tracking form-loads and form-submissions with google analytics events

So running that code inside of rich text in an embedded form works for the hidden field value getting populated, but not for the GA event.

I think I've seen folks utilize the JS API commands at the embed/ load form snippet. Should I give it a shot there?

Highlighted
Level 10 - Community Moderator

Re: Tracking form-loads and form-submissions with google analytics events

You have two glaring race conditions in your code that prevent it from working.

One is that you aren't guaranteeing the availability of the GA library when MktoForms.whenReady executes.

Two is that (if you added the equivalent code onSuccess) you are not ensuring that the GA hit is logged before redirecting the browser to the next page.

I have been writing up this very frequently seen situation on my blog, so if you can sit tight I'll explian it further there.

Highlighted
Anonymous
Not applicable

Re: Tracking form-loads and form-submissions with google analytics events

Was this ever answered? Similar to Martin, I also would like to implement something like this for our company but run up against a wall.

Highlighted
Level 10 - Community Moderator

Re: Tracking form-loads and form-submissions with google analytics events