APIs & Integrations

knowmadweb
Participant | Gold Partner
Participant | Gold Partner

Passing custom form data to a response page

Hi, I’m trying to pass a value from a link to a landing page through to the response page. I can successfully get the value to the original landing page.

However, when the form is submitted, the data does not get passed forward to the response page (I’m using an inline response but would expect similar behavior with a custom URL).

I’ve tried using Javascript to add a hidden form field (didn’t work) and hacking the hs_context form element (also didn’t work). Is there anything that I’m overlooking that could make this work?

Here’s the use case for interested parties:
Our client has a product catalog with over 100 products. They are happy to make a technical data sheet available to registered users. I’m using a smart field to determine whether the visitor is known.

If the visitor is known, they are given a direct link to the PDF file. If not, my goal is to be able to allow new visitors to register with the site then immediately get access to the PDF. I can pass along the url of the PDF file via the smart field. However, that data is not surviving the form submission.

UPDATE (Aug 2): I was able to create a new contact property and use Javascript to set the value of this property to the desired URL (following the post at [SOLVED] Populate Form with Value while loading or $(document).ready()). With this approach, I’m able to use the contact property setting to set the link. However, the response page is loading faster than the property is getting update in HubSpot. When the form is submitted from an incognito browser with no visitor history, the link is empty. If I refresh the page, the link gets set. Is this a bug? Is there another way to access the form submission data from the response page?

0 Upvotes
1 Reply 1
knowmadweb
Participant | Gold Partner
Participant | Gold Partner

Passing custom form data to a response page

Today, I tried to redirect to a Website Page instead of a Landing Page to see if there would be any difference in behavior. No dice – it seems like the contact information is just not getting updated on the server in a timely manner. It’s a bit disappointing that HubSpot doesn’t provide a mechanism to access form submission information from the response page.

In any case, here’s the workaround solution that I came up with that is working.

  1. Redirect to a Landing Page. Wait for page to load then wait another 500ms.
  2. Use a window.location.href function to redirect to a Website page. This allows the server time to get the info submitted in the form to get updated on the server.

I’ve included my source code below. Hopefully, this is a temporary bug that HubSpot will address in a future update.

William

<script> // Wait for page to load $(window).load(function(){ //console.log('page loaded'); window.setTimeout(redirectUrl,500); }); // Redirect to a website page in order to give server time to load the contact.pdf_url value function redirectUrl() { //console.log('redirectUrl called'); window.location.href = 'http://YOURURL'; } </script>

0 Upvotes