Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pass the GET parameters / url variables / query string, from a hubspot form to your redirect/thank-you page. Apparently, to do this now, you have to manually define the redirect url in the script. It's not exposed in hsContext anymore.
* 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
* Form redirect
* Written in 2015 by Mike Axiak <>
* Updated in 2016 by Seth Meranda <>
* Updated in 2017 by Ray Aguilar <>
* 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 <>.
function appendFormData (form) {
* Define your redirect URL here. (Yeah, it's
* stupid... But Hubspot apparently doesn't
* expose the redirect url on embedded forms
* anymore. Or at least I can't find it...)
var redirect = "";
var appendFields = function (url, values) {
var data = {};
$.each(values, function (i, item) {
if ( !== "hs_context") {
data[] = item.value;
if (url.match(/\?/)) {
return url + "&" + $.param(data);
} else {
return url + "?" + $.param(data);
var $hsContext = form.find("input[name='hs_context']");
var hsContext = JSON.parse($hsContext.val());
hsContext.redirectUrl = appendFields(redirect, form.serializeArray());
* add this to the embed form onFormSubmit callback
onFormSubmit : function($form, ctx) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.