是否可以将跟踪添加到 Hubspot 表单提交按钮

Is it possible to add tracking to Hubspot form submit button

有谁知道是否可以将跟踪代码添加到 Hubspot 表单中的提交按钮?我已尝试使用 onFormSubmit 属性添加跟踪代码,但我没有获得提交按钮点击的任何跟踪结果。也许我的代码格式不正确。?我在下面包含了我的代码以供参考。出于安全原因,我删除了门户和表单 ID。

谢谢!

<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
hbspt.forms.create({ 
css: '',
cssClass:'.hs-form fieldset {max-width: 100%;}',
portalId: '',
formId: '',
inlineMessage: '<iframe style="width:100%; height:800px;" scrolling="auto" src="URL goes here"></iframe>',
onFormSubmit: 'mmConversionTag(704048, this, "_self"); ga("send","event","button","click","product distributors")'
});
</script>

onFormSubmit 是一个回调,你应该把它包装在一个匿名函数中而不是传递一个字符串:

 hbspt.forms.create({ 
    css: '',
    cssClass:'.hs-form fieldset {max-width: 100%;}',
    portalId: '',
    formId: '',
    inlineMessage: '<iframe style="width:100%; height:800px;" scrolling="auto" src="URL goes here"></iframe>',
    onFormSubmit: function(){
       mmConversionTag(704048, this, "_self");
       ga("send","event","button","click","product distributors");
    }
 });