If the form is on a COS page, then i think it is easier than you think (you won’t even have to do anything api related) Go to edit the form module Even if you are going to an internal page, click redirect to external URL [04%20AM] redirect to your desired page and attach whatever contact property you desire via query parameters. http://redirect-address.com/the-page?token={{contact.your\_internal\_property\_name}} After you click save, you can see your link when you hover over test li…
@derekcavaliero you are the man. This answer saved me a lot of time!
Hi @John I came across this thread and we are having a very similar issue. I am passing just the email parameter to test from a hubspot form to a wordpress page (that includes the HubSpot tracking cod) . First line is the parameter they way i have it in the redirect and then the second is how it actually comes out. Any suggestions?
One thing I did not mention in my solution was to make 100% sure that you exclude any PII in the form data from being collected by Google Analytics.
Since we’re talking about appending the data to the URL via a query string - GA will automatically capture that data inside its pageview reports. This means you’ll likely need to add some custom logic around your tracking to make sure you adhere to the GA terms of use regarding collection of PII.
If you’re using GTM (Google Tag Manager) to implement your web tracking (if you aren’t I highly suggest you investigate) - this article is a great resource for understanding how to exclude data from being collected: Simo Ahava’s blog
I built off of Derek’s answer because I needed to use the built in landing pages, I was not using the form embed. The following worked for me.
<script>
//code for redirecting to brew ninja signup flow after they enter their email
$(document).ready(function() {
setTimeout(function() {
var form = $('[data-form-id=xxx-xxx-xx-your-form-id]');
form.submit(function() {
var email = $('[data-form-id=xxx-xxx-xx-your-form-id]').find('[name=email]').val();
setTimeout(function() {
window.location.href = 'https://yoursite.com?email=' + email;
}, 500);
});
}, 500);
});
</script>
This absolutely was a great solution for me. I was trying to redirect to different thank you pages based on a <select> choice but the browser was not accepting “onFormSubmit”. I think there was a conflict on the page. Pulling the logic out of the JS that writes the form to the page is key. I replaced ‘$’ with ‘jQuery’ to avoid conflicts and - voila - it worked. Thanks!
Hi @derekcavaliero - when i embed this code onto my site (after adjusting the code with my portal ID, etc, the form doesn’t even appear on my page. Any advice?
@derekcavaliero I see you have been helping out people with this for years, so you migth be able to help!
I’m trying to achieve what other people here are - appending utm values upon form submission so people don’t have to input their info again.
I’ve created this test page here - Speech Analytics Platform for CX | Chattermill (pass: 1234567) and embedded a test form.
Ideal state would be that on successfull form submission, users are redirected to (https://meetings.chattermill.com/meetings/gmirazchiev/meetings-scheduler-for-demopricing) and values for email, first name and last name are appended to the URL.
I’ve tried several methods and some of the code snippets here, but can’t get it to work.
The redirect element works and redirects to the correct url, but the form data isn’t appended to the URL
The embed snippet I’ve used is:
hbspt.forms.create({
region: “na1”,
portalId: “613982”,
formId: “eb6ca632-e7fb-424c-ba32-ac9184679fb2”,
inlineMessage: ‘Your submit message here’,
cssClass: “hs-s-contact-form”,
onFormSubmitted: function($form){
setTimeout( function() {
var formData = $form.serialize();
window.location.replace(“https://meetings.chattermill.com/meetings/gmirazchiev/meetings-scheduler-for-demopricing?” + formData);
}, 250 ); // Redirects to url with query string data from form fields after 250 milliseconds.
}
});
Do you have any idea what I’m doing wrong?
Thanks
Actually - you’ll have problems with that - because HubSpot doesn’t pass the $form argument to that callback like it does for onFormSubmit (this is very dumb and I had a lengthy chat w/ HubSpot support about it).
I would reccomend using onFormSubmit over onFormSubmitted - or if you plan on using onFormSubmitted - you’ll need to “cache” the $form in a global variable which would mean setting it via onFormSubmit and then referencing it in the onFormSubmitted callback.