# Pull Query String from First Page Seen

**URL:** <https://community.hubspot.com/t/pull-query-string-from-first-page-seen/89609>\
**Category:** CMS Development\
**Tags:** workflows\
**Created:** [September 13, 2023, 10:09pm UTC](https://community.hubspot.com/t/pull-query-string-from-first-page-seen/89609 "2023-09-13T22:09:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanbreneman](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@ryanbreneman](https://community.hubspot.com/u/ryanbreneman)\
**Post date:** [September 13, 2023, 10:09pm UTC](https://community.hubspot.com/t/pull-query-string-from-first-page-seen/89609/1 "2023-09-13T22:09:50Z")

</div>

I’m looking for a way to pull the query strings from the First Page Seen url. I want to pass this information into their respected fields within the contact property, i.e., utm\_source, utm\_medium, etc.

Was wondering if someone has already done this so I don’t have to create the code myself.

---

<div class="post-metadata">

**Author:** ![PamCotton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pamcotton/32/47916_2.png) [@PamCotton](https://community.hubspot.com/u/PamCotton)\
**Post date:** [September 14, 2023, 7:15pm UTC](https://community.hubspot.com/t/pull-query-string-from-first-page-seen/89609/2 "2023-09-14T19:15:21Z")

</div>

Hello @ryanbreneman, thank you for posting in our Community!

To our top experts [@Mike\_Eastwood](https://community.hubspot.com/t5/user/viewprofilepage/user-id/9259) @StefaniUAT - @tjoyce any recommendations to @ryanbreneman?

Thank you,

Pam

---

<div class="post-metadata">

**Author:** ![ryanbreneman](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@ryanbreneman](https://community.hubspot.com/u/ryanbreneman)\
**Post date:** [September 14, 2023, 7:50pm UTC](https://community.hubspot.com/t/pull-query-string-from-first-page-seen/89609/3 "2023-09-14T19:50:17Z")

</div>

Thank you @PamCotton, appreciate the hello and the help.

Just to include a little more information. I’m trying to use the Custom Code within a workflow. And this is what I’ve been trying but haven’t gotten it to work. Not sure if this is the best way.

```lia-code-sample
exports.main = async (event, callback) => {
 / *****
 Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.
 ***** /
 const firstpageseen = event.inputFields['hs_analytics_first_url'];
 const queryString = firstpageseen.parse(window.location.href).query;
 const ParameterName = 'utm_source'
 const parameterValue = queryString[ParameterName]
 / *****
 Use the callback function to output data that can be used in later actions in your workflow.
 ***** /
 callback({
 outputFields: {
 utmsource: parameterValue
 }
 });
}

```
