SOLVED

Re: Running conversion code on form submission?

Go to solution
Jose_Rafael_Par
Level 3

Running conversion code on form submission?

My team wants to remove the thank you page between submitting a form and seeing a white paper PDF, so that clicking the submit button opens the PDF directly. I know how to do that fine, but the problem is that I can't embed our Google Adwords conversion code in the PDF. 

Does anyone know how to run the adwords conversion code when the user clicks the submit button on the form?
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Running conversion code on form submission?

Jose & Jenny:

You can do that with some JavaScript! Eric Hollebone wrote about it here. On that page, you want to use the third method: using Marketo's pre-submit.

You can either put this code in the template or the individual landing pages under "Landing Page Actions > Edit Page Meta Tags." Then you can paste this code into the "Custom HEAD HTML:" section. 

Depending on whether or not your template calls jQuery before, you might not need the first line of Javascript.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript"> jQuery(document).ready(function($){
  // bind to the form submit
  $(&#039;#mktFrmSubmit&#039;).submit(function(event) {
 
    // test to see if at least one of the fields is filled in ...
 
    // inject the google adword conversion code
    var google_conversion_id= ... your google adwords id ...,
      google_conversion_language="en",
      google_conversion_format="3",
      google_conversion_color="ffffff",
      google_conversion_label='... your google conversion label ...",
      google_conversion_value=0;
    $.getScript( "http://www.googleadservices.com/pagead/conversion.js" );
  });
});
</script>

The commented "// test to see if at least one of the fields is filled in ..." is where you can add in simple validation to make sure the form is filled before counting it as an AdWords conversion. This can be as simple or detailed as you want.

This form still works (when replacing the appropriate fields) without field validation, but using the code without validation means that users hitting the "submit" button will be counted as conversions even if the form throws an error at them. So if you're using this without validation, just be wary of having a higher amount of AdWords conversions than actual leads in your database. Doing validation might be overkill, depending on your specific use!


Best Regards,
Edward Unthank
SEO/Web Specialist

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Re: Running conversion code on form submission?

I am having the same issue - let me know what you hear

Thanks,
Jenny

jenny@tegile.com
Anonymous
Not applicable

Re: Running conversion code on form submission?

Jose & Jenny:

You can do that with some JavaScript! Eric Hollebone wrote about it here. On that page, you want to use the third method: using Marketo's pre-submit.

You can either put this code in the template or the individual landing pages under "Landing Page Actions > Edit Page Meta Tags." Then you can paste this code into the "Custom HEAD HTML:" section. 

Depending on whether or not your template calls jQuery before, you might not need the first line of Javascript.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript"> jQuery(document).ready(function($){
  // bind to the form submit
  $(&#039;#mktFrmSubmit&#039;).submit(function(event) {
 
    // test to see if at least one of the fields is filled in ...
 
    // inject the google adword conversion code
    var google_conversion_id= ... your google adwords id ...,
      google_conversion_language="en",
      google_conversion_format="3",
      google_conversion_color="ffffff",
      google_conversion_label='... your google conversion label ...",
      google_conversion_value=0;
    $.getScript( "http://www.googleadservices.com/pagead/conversion.js" );
  });
});
</script>

The commented "// test to see if at least one of the fields is filled in ..." is where you can add in simple validation to make sure the form is filled before counting it as an AdWords conversion. This can be as simple or detailed as you want.

This form still works (when replacing the appropriate fields) without field validation, but using the code without validation means that users hitting the "submit" button will be counted as conversions even if the form throws an error at them. So if you're using this without validation, just be wary of having a higher amount of AdWords conversions than actual leads in your database. Doing validation might be overkill, depending on your specific use!


Best Regards,
Edward Unthank
SEO/Web Specialist
Jose_Rafael_Par
Level 3

Re: Running conversion code on form submission?

Thanks, Edward!