在重定向URL上使用HubSpot表单数据
Use HubSpot Form Data on redirectURL
我正在寻找一种方法,将HubSpot表单的数据发送到提交后重定向到的url,这样我就可以使用它来自动填充该页面上自定义表单中的字段。我试着把我需要的数据存储在一个cookie中,但运气不好。我还在github上找到了一个脚本,用于将数据附加到重定向URL,并在我的登录页模板代码中设置它,但一直无法使其工作:
https://gist.github.com/axiak/2bf8f43d9d4a5f9c883f
/**
* Append the form data from a HubSpot form automatically
* to the redirect URL query parameters. These values can
* then be used on the form to modify the user experience
* of the Thank You page
*
* LICENSE
* Form redirect
* Written in 2015 by Mike Axiak <maxiak@hubspot.com>
* To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
* You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
(function() {
var $ = jQuery;
var appendFields = function (url, values) {
var data = {};
$.each(values, function (i, item) {
if (item.name !== "hs_context") {
data[item.name] = item.value;
}
});
if (url.match(/'?/)) {
return url + "&" + $.param(data);
} else {
return url + "?" + $.param(data);
}
};
$(function () {
$("body").on("submit", "form.hs-form", function (e) {
var $form = $(this);
var apiUrl = $form.attr("action");
var $hsContext = $("input[name='hs_context']", $form);
var hsContext = JSON.parse($hsContext.val());
hsContext.redirectUrl = appendFields(hsContext.redirectUrl, $form.serializeArray());
$hsContext.val(JSON.stringify(hsContext));
});
});
})();
我认为您可以使用Hubspot的开发人员API获取与联系人相关的所有数据。Hubspot将用户令牌存储为cookie名称"hubspoutk",一旦您获取了该名称,就可以使用
GET /contacts/v1/contact/utk/:contact_utk/profile
以获取与当前联系人关联的所有属性,其中应包括他们在第一页中填写的所有内容。
有关api调用的更多信息。
希望它仍然相关。
当您调用要创建的表单时,需要定义"重定向URL"。
hbspt.forms.create({
redirectUrl:"www.google.com",//here you go
formId: '<your form id>',...}
那么你从Github中找到的代码就可以工作了。
如果你在Hubspot管理面板控制器中的某个地方定义重定向URL,不幸的是,我还没有找到在Github中使用这些代码来查看检索它的方法。
相关文章:
- 可以't让我的if语句处理js中的html表单输入
- 如何使用WCF服务和javascript表单post上传.doc文件
- Javascript生成的表单未提交
- 如何使用javascript或html下载PDF格式的填写表单
- HTML表单提交时未执行外部函数
- 如何将输入(type=text)从html表单传递到javascript函数
- 通过单击表单中的按钮,在代码生成中使用javascript生成字母数字代码
- Ajax发布表单序列化,发布引号'
- 多级HTML表单
- 后焦点更改为IE 11中的地址栏,而不是转移到表单中的下一个控件
- 在验证和发送邮件后更改联系人表单的 html
- jQuery表单添加不适用于下拉列表
- Rails/JSON:如何将JSON用于jquery UI自动完成表单
- 如何从pdftron webviewer获取表单数据
- JS验证ajax返回的html中的表单数据
- Javascript更新孙窗口中的表单元素
- 解析javascript表单验证器
- 在重定向URL上使用HubSpot表单数据
- 是否可以将跟踪添加到Hubspot表单提交按钮
- 防止hubspot表单提交- jQuery验证