如何在另一个表单对象中加载不同的Marketo表单?

时间:2014-08-08 14:42:48

标签: javascript jquery forms marketo

您好我正在使用Marketo的表单2.0 api尝试在我们的网站上构建一个顺序表单(我想将一个大表单分成两个部分)。我们还希望能够在用户点击" next"时跟踪放弃率。加载表单的第2部分。所以当第一个提交时,我试图让另一个表单加载。有没有人这样做过?或者有更好的方法来做到这一点。到目前为止,这是我的代码。

<script src="//app-sjp.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_333"></form>
<script>
    MktoForms2.loadForm("//app-sjp.marketo.com", "466-AGZ-592", 333, function(form) {
        form.onSuccess(function(callback) {
            form.getFormElem().hide();
            MktoForms2.loadForm("//app-sjp.marketo.com", "466-AGZ-592", 334, function(forms) {
                form.getFormElem().show();
            });
        });
    });
</script>

任何建议都将不胜感激。感谢

-John

1 个答案:

答案 0 :(得分:1)

您的实施是有道理的。要跟踪放弃率,您可以将Marketo's Munchkin web trackingMarketo Form 2.0 methods一起使用。

在下面的示例中,我将事件(表单1加载,表单2加载,表单2提交)捕获为单击事件,并通过Munchkin将数据发送到Marketo。

//Load Marketo's Munchkin tracking
<script src="http://munchkin.marketo.net/munchkin.js"type="text/javascript"></script>
<script src="//app-sjp.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_333"></form> 

<script>
    MktoForms2.loadForm("//app-sjp.marketo.com", "466-AGZ-592", 333, function(form) {
    //Measures form 1 load event .
    Munchkin.munchkinFunction("clickLink",{href:"/form1load"})
    form.onSuccess(function(callback) {
    //Measures form 2 load event. This should be equal to form 1 submission count.
        Munchkin.munchkinFunction("clickLink",{href:"/form2load"})
        form.getFormElem().hide();
        MktoForms2.loadForm("//app-sjp.marketo.com", "466-AGZ-592", 334, function(form) {
            form.getFormElem().show();
            //Measures form 2 submission. Uses Marketo Form's onSuccess method.
            form.onSuccess(function(values, followUpUrl){
                Munchkin.munchkinFunction("clickLink",{href:"/form2submission"})
                //Keep user on same page after form submission
                return false;
            });
        });
    });
});
</script>