Using GTM to track Marketo form fills | Community
Skip to main content
New Participant
May 5, 2022
Solved

Using GTM to track Marketo form fills

  • May 5, 2022
  • 2 replies
  • 9003 views

Hi, 

 

I am completely new to Google Tag Manager and Analytics and I am trying to implement Google Tag Manager tracking on our Marketo embedded forms so it shows up in our Google Analytics Top Events. I have followed this blog - https://nettlesnet.com/marketo-form-tracking-google-tag-manager-analytics/

Which has allowed me to see when someone fills out a form, when it's been submitted and when it's a success in GTM Tag Assistant. So I think the Event - Form Listener tag is working - I used the code from the blog above - but it doesn't look like my custom event trigger or event form success tag is working to send the information through to Google Analytics. 

 

If anyone has any advice that would be very appreciated. 

 

Thanks. 

 

Best answer by Darshil_Shah1

There's an extra "," character in the form.onSubmit function at the end of 'marketo.form_id': form_id line. Can you try by replacing the form.onSubmit function definition with the below?

form.onSubmit(function(){ dataLayer.push({ 'event': 'marketo.submit', 'marketo.form_id': form_id }); });

 

2 replies

Darshil_Shah1
Community Manager
May 5, 2022

I wasn't able to access the link you shared (it says Access denied) so can’t see what have you followed through. But if you're setting this in the GTM, you would need to create the Google Analytics event tag, and set it to trigger on the events you would wanna capture in the GA (i.e., form view, submission, etc.).

 

I think referring this article should give you some idea: chrisgoddard.blog/2018/02/03/how-to-track-marketo-forms-in-google-analytics-using-google-tag-manager/

 

 

New Participant
May 9, 2022

Hi Darshil, 

 

Thanks, I am getting parse errors when I try to use the code suggested in this article:

<script>
  (function(document, window, undefined){
 
    var dataLayer = window.dataLayer;
 
    try {
if(window.MktoForms2){
  window.MktoForms2.whenReady(function(form){
    var form_id = form.getId();
    var $form = form.getFormElem();
     
    dataLayer.push({
      'event': 'marketo.loaded',
      'marketo.form_id': form_id
    });
     
    form.onSubmit(function(){
      dataLayer.push({
        'event': 'marketo.submit',
        'marketo.form_id': form_id,
      });
    });
     
    form.onSuccess(function(values, followUpUrl){
      dataLayer.push({
        'event': 'marketo.success',
        'marketo.form_id': form_id,
        'marketo.form_values': values,
        'marketo.follow_up_url': followUpUrl
      });
 
      if({{Debug Mode}}){
        console.log(values);
        return false;
      } else {
        return true;
      }
    });
               
  });
}
Darshil_Shah1
Darshil_Shah1Accepted solution
Community Manager
May 9, 2022

There's an extra "," character in the form.onSubmit function at the end of 'marketo.form_id': form_id line. Can you try by replacing the form.onSubmit function definition with the below?

form.onSubmit(function(){ dataLayer.push({ 'event': 'marketo.submit', 'marketo.form_id': form_id }); });

 

New Participant
May 5, 2022

@ellena_frost 
There are couple of post already solved in community on Google Tag Manager Form Fill Out Tracking.

Mostly this post will be helpful to resolve your issue. Thank you.

 

Thanks,

Avinash Jadhav