Is it possible to get query params in referrer?

Hi!
I have two websites, and one has a link to another.
What I want is when the user goes from the first site to second, to see all the query params that were set in the first website.

I was hoping it is possible with “referrer” in the “browser” component. But it passes only the url, without query parameters.

Is it possible to achieve that?

I think browser1.location.href is what you need.

How is the user navigating? Is it a button click?

For the button/link that is used to get to the other site, append the search part of the browser location

e.g.
for get variables in the url i.e. https://somedomain.com?abc=1&xyz=somethingelse

<a href="#" dmx-bind:href="https://yourotherdomain.com{{browser1.location.search}}">Go to other site</a>

for parameters as paths https://somedomain.com/1/somethingelse
e.g.

<a href="#" dmx-bind:href="https://yourotherdomain.com{{browser1.location.pathname}}">Go to other site</a>

@TomD @bpj
Thanks for the feedback, guys! But I afraid I wasn’t clear about my question.
You suggest the “browser1.location” that is about the current page that I am on. But I need to know the page the user came from.

So I better describe the situations straight.
First website not mine, and currently I can’t affect it. This site has a link in the menu that leads to my site.
That first site has a “city” query param. For example, www.firstsite.com/?city=london

And when a user comes from this first site to my site by this link, I want to see this query param to keep his city selection.
As I understand, “browser1.referrer” is exactly the thing for this, as it allows you to see the website, user came from.

But in Wappler “browser1.referrer” only shows “www.firstsite.com”, not “www.firstsite.com/?city=london

I’m pretty sure that info won’t come unless the source site actively sends it

1 Like

I tested this locally and the referrer seems to show the ?param=value

1 Like

Modern browsers allow less then older browsers because of security. The default now is that when making a cross origin request it will only include the origin in the referer and not the full url.

You can set it to unsafe:

Using a meta tag

<meta name="referrer" content="unsafe-url">

On the link tag

<a href="https://other.site" referrerpolicy="unsafe-url">

Using header

Referrer-Policy: unsafe-url
2 Likes

Got it now, big thanks!
So, “browser.referrer” in Wappler works properly and shows full url, but only if initial website specifically allowed it.