APIs & Integrations

Charles_Bannist
Member

How to track successfully submitted forms which use inline feedback

I need to track AdWords Conversions whenever a form is successfully submitted. A couple of points:

  • I can’t use GTM
  • The form doesn’t re-direct to a thank you page

I have a solution but looking at Google’s tag tool I’m sometimes getting a “No HTTP response detected” error. I can submit the form and it works fine, then I’ll submit it again two minutes later and I see an error.

Okay, here’s the code:

<script type="text/javascript">

var url  = window.location.href
var index = url.indexOf("submissionGuid")
var track = index>=0 ? true : false;
console.log("track: " + track)
 /* <![CDATA[ */
  goog_snippet_vars = function() {
    var w = window;
    w.google_conversion_id = 10000095;
    w.google_conversion_label = "MxO00000000wM";
    w.google_remarketing_only = false;
  }
  // DO NOT CHANGE THE CODE BELOW.
  goog_report_conversion = function(url) {
    goog_snippet_vars();
    window.google_conversion_format = "3";
    var opt = new Object();
    opt.onload_callback = function() {
    if (typeof(url) != 'undefined') {
      window.location = url;
    }
  }
  var conv_handler = window['google_trackConversion'];
  if (typeof(conv_handler) == 'function') {
    conv_handler(opt);
  }
}
/* ]]> */
if(track){
  goog_report_conversion(url)
}


</script>
<script type="text/javascript"
  src="//www.googleadservices.com/pagead/conversion_async.js">
</script>

Logic:

  • When the form is submitted a “submissionGuid” is added to the URL.
  • Check “submissionGuid” is present, fire the tracking code if so
  • Use the code AdWords provides for onClick() events, but wrap in an if so it instead runs when the “submissionGuid” is present

Sounds pretty straight forward, yes!? I also tried the default AdWords Tracking code but see the same issue.

Is there a better way?

Thanks

0 Upvotes
2 Replies 2
Charles_Bannist
Member

How to track successfully submitted forms which use inline feedback

Thanks @Derek_Gervais I’ll look into that.

Will also use GTM (initially couldn’t at the client’s request) which I’m sure will help.

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How to track successfully submitted forms which use inline feedback

Hi @Charles_Bannister,

You might consider trying to tweak the form embed code to make use of the onFormSubmit callback function:

How to customize the form embed code

This is a list of options that you can use if you just need to tweak a default hubspot form. If you need complete control over the styles and actions of your form, you will still want to use the Forms API.

0 Upvotes