Passing page ID from LP to TY page, through HubSpot form


One of our clients is looking to utilise a single thank you page for all of their landing pages.

The motivation behind this is to save time and reduce complexity for marketers, and to reduce likelihood of inconsistency. So a marketer creates a LP for an offer, tags with necessary categories / business areas / content types (we have developed a tagging custom module using HubDB for this), but then they do not need to create a thank you page.

The ideal idea is that the TY page is passed the ID of the referring LP. However, at the very least the post data would give me something to look up the referring page via the API. From there, the TY page would grab relevant related content etc.

**FYI - the form MUST be a HubSpot form. The landing pages already have a Form module and replacing with custom HTML forms is not an option. **

According to this page the following variable should contain the POST data:

{{ request.post_dict }}

However, all it contains is the submission GUID. Seeing as there is no form submissions API, I have nothing to look up to try to grab related content etc.

Any ideas anyone?


Hi @craigivemy,

That's a fairly tricky situation. First thing to cover is that the site you're linking to out of date; the supported HubL variable are here:

The tricky part is that since the form is a default HubSpot form on a HubSpot page, there aren't any out-of-the-box solutions to add information to the redirect URL. There are some solutions that take advantage of the customizability of an inline form, described here:

You might consider taking some inspiration from the post above and using an inline thank you instead of a redirect URL; you could add some Javascript to the page that listens for the onFormSubmit event, and trigger a redirect that includes the relevant information you need.


As @Derek_Gervais mentioned, using a native HubSpot form module is going to give you problems because you cannot modify the onFormSubmit() callback method on a global level (I have identified this as a problem on many occasions for reasons just like this) - it can only be done directly inside the hbspt.forms.create() method.

What you could do (and I have done in the past). Is create your own HubSpot form module where you can disable the default redirect for the form and instead hard-code your TY page URL into the onFormSubmit() callback with the HUBL page ID appended (I think you can access these variables inside a global module but I am not sure). If you can't directly access the HUBL variable inside the module - you can localize the HUBL variables you need to use by attaching them the the window inside your <head> output in your site settings.

You can even get fancy and add a HubSpot form field inside the custom form module itself so that the ease of use for your marketing team is on par with standard HubSpot forms.


@derekcavaliero - are you saying the following CANNOT be used? I have used these before.

@Derek_Gervais thanks for the - assuming the above link is not also out of date(!) it means I can still use the form module so marketers can select the form (rather than using modified embed code) and choose workflow options etc. @derekcavaliero seems to think the onFormSubmit can only be used directly in embed code, but link above suggests otherwise?

If the above link is correct this way the only thing the user needs to remember is to select inline thank you message.

Make sense?


@craigivemy sorry for the confusion. It has been a little while since I had looked at the documentation to see if anything new had been posted - (been heads down on some non-HubSpot work as of the past 3-4 months). Looks like they finally got around to implementing my suggestion on the callbacks :D.

That in theory should work - if you can change the submission action of the form using the onBeforeFormInit event. The docs do mention this which could thwart the overall idea of what you are trying to do:

Please note: These events are non-blocking, so it's not possible to prevent a form submission using the onFormSubmit callback.

In theory though - you could probably use the onFormReady event and modify the hs_context hidden field value in the form to point to whatever shared TY page you plan on using with a query string of the page ID appended as well.


@derekcavaliero thanks - I keep finding things that are out of date, so wanted to check!

Makes sense, that's great!