我的团队希望为我们自己网站上托管的目标网页设置一个主Marketo表单。他们在Marketo中设置了隐藏字段和添加说明的表单,并且我已经为他们提供了根据需要分配广告系列ID,资产和重定向网址的方法。这可以通过生成以下代码来实现:
<script src="//app-sj05.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_ourFormID"></form>
<script>
MktoForms2.loadForm("//app-sj05.marketo.com", "ourID", ourFormID, function(form) {
// Set values in hidden fields to determine campaign and asset to serve
form.vals({
"Campaign_Id__c":"assignedCampaignID",
"Campaign_Asset__c":"assignedCampaignAsset"
});
// Override redirect URL set in Marketo
form.onSuccess(function(values, followUpUrl) {
location.href = "redirectURL";
// Return false to prevent the submission handler continuing with its own processing
return false;
});
});
</script>
下一步是仅在广告系列尚未包含在引荐网址中时指定广告系列。因此,我需要某种if / then语句来查看隐藏的广告系列ID以查看是否存在值 - 并且仅在没有值的情况下分配值。我不是任何一个javascript高手,我不确定什么是Marketo API的最佳方法。有人能用最后一点if / else来帮助我吗?
答案 0 :(得分:0)
如果调用不带参数的form.vals(),它将返回对象中表单的所有值。所以它看起来像这样:
if (!form.vals().Campaign_Id__c){
form.vals({"Campaign_Id__c": myValue});
}
答案 1 :(得分:0)
感谢Sanford Whiteman通过Marketo支持论坛,这就完成了工作:
(?s) - matches everything as a single line
SI - matches SI
(.*$) - matches and captures everything after that.