APIs & Integrations

Robarrer
Member

Get user Source

Hello everyone.

I need to detect the "source" of a user navigating our website, and send it as a "query-param" in some of the CTAs we have.

 

HubSpot does this automatically when a user fills out a HubSpot form, as it stores the source information in the "origin" field.

 

However, I need the user source as a "query-param" in a button link, so we can send it to a 3rd party app.

 

Thanks in advance

0 Upvotes
2 Replies 2
LewTalon
Participant | Partner
Participant | Partner

Get user Source

You can get the URL Params within a custom module or JS file using the URLSearchParams 

 

For example:

const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('myParam');

 You can then pass the URL parameters to your 3rd party app

0 Upvotes
Robarrer
Member

Get user Source

Thanks for your reply.

The problem is some origins do not generate UTM params in the URL.

For example, if a user comes from a LinkedIn link, and is redirected to the blog.

Another example, is a user that comes from organic search in Google, in this case, the URL won't have UTM params as well.

But, Hubspot can define the user source in all cases, as long as the user fills out one of their forms.

0 Upvotes