# Using javascript to pull parameters from URL to generate content

**URL:** <https://community.hubspot.com/t/using-javascript-to-pull-parameters-from-url-to-generate-content/54110>\
**Category:** CMS Development\
**Tags:** javascript\
**Created:** [March 30, 2022, 5:32pm UTC](https://community.hubspot.com/t/using-javascript-to-pull-parameters-from-url-to-generate-content/54110 "2022-03-30T17:32:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterS72](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@PeterS72](https://community.hubspot.com/u/PeterS72)\
**Post date:** [March 30, 2022, 5:32pm UTC](https://community.hubspot.com/t/using-javascript-to-pull-parameters-from-url-to-generate-content/54110/1 "2022-03-30T17:32:46Z")

</div>

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](http://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](http://externalpage.com/page1?d=3433333&name=bob)).

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

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [March 31, 2022, 4:01pm UTC](https://community.hubspot.com/t/using-javascript-to-pull-parameters-from-url-to-generate-content/54110/2 "2022-03-31T16:01:50Z")

</div>

@piersg

What do you have to say about this?

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [April 1, 2022, 8:50am UTC](https://community.hubspot.com/t/using-javascript-to-pull-parameters-from-url-to-generate-content/54110/3 "2022-04-01T08:50:15Z")

</div>

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.

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

```
