Using javascript to pull parameters from URL to generate content

We have an external system that will be redirecting users to our landing page.

We would like to include parameters in the landing page URL that can be read by javascript on the Hubspot page itself and included in a URL.

Example: External system send the user to a Hubspot landing page (URL would be, www.domain.com/landingpage1?id=3433333&name=bob)

The Hubspot landing page would include javascript that generates a button with a link to an external page that includes those parameters. (URL: externalpage.com/page1?d=3433333&name=bob).

Is this possible? What is the best way to do this?

@piersg

What do you have to say about this?

Hi @PeterS72 (thanks @dennisedson). Yeah, you can get URL query parameters and add them to a link with JS. Very easy if you all you’re doing is copying the parameters to the button’s href.

const params = window.location.search;
const btn = document.getElementById('my_btn');
btn.href = `${btn.href}${params}`;