How to add a URL parameter to a page?

Whenever a user logs in using a popup or my global menu, I’d like to pass some data through a URL parameter. This is useful for many reasons, e.g. telling the app which page they were on before logging in or connecting the logged-in user to some data that was being worked on before logging in.

I know that I can add a URL parameter by selecting Go to page... and then checking Send more parameters to the page

If you choose the current page when you do this, it doesn’t even refresh, it just adds the URL params to the page.

However, reusable elements could be on any page, and there’s no way to tell it to go to a dynamic page (“Current Page”). So I’m not seeing an easy way to add a URL parameter to a page.

Use an ‘Open External Website’ action (or a link element)…

1 Like

Even with a reusable element, I would think the page someone is going to be navigated to from some sort of action performed from the element would not be different from other instances of the same reusable element. So, why couldn’t you just have a generic page it navigates to, send the parameters to that page, and have your conditionals on other elements firing if/then on said parameters?

1 Like

That generates a page refresh which breaks the flow.

This needs to work the first time a user lands on a page, e.g. after typing the domain into the browser or landing from a Google search, so there is not a reliable page it’s coming from.

I don’t want to send the user to another page (or even refresh the current page). I want to just add a URL parameter to the URL of the current page without doing anything else.

You can do that on page load then with a conditional only when page parameter is empty ??

1 Like

I want this to happen following a user action, not page load.

Ok, same principle should apply. “User action” triggers a workflow conditionally if page parameter is empty. right?

Just use a go to page > same page | send parameter should just append a parameter to the url. Then you can hide or show other elements based off of the url parameter value

1 Like

I’m not sure I’m following. I know how to trigger a workflow. What I’m trying to figure out is how to add a parameter to the current page URL without refreshing or going to a new page.

This is exactly the crux of the problem. This is a reusable element that could be used on any page. And since that dropdown (the one I screenshot in my post) does not allow dynamic content, there’s no way to make sure that the “current page” is selected.

What’s your objective? I understand you want to send parameters to a page. Describe the workflow or UX for me.

And why can’t you use open external website with the page and parameters appended that way? The refresh?

Have you tried installing the Toolbox plugin and using code

var url = new URL(“somedomain.com”)

url.searchParams.append(‘z’, 12)

or something

rjs

this works for me and you can put your own data or dynamic data.

option is the key and 15 is the value

1 Like

I have several use cases for this, here’s one.

A user who already has an account visits the app from a new computer and does not log in. They add several items to their shopping cart. That shopping cart is associated with the visitor user ID. Since they’re not logged in, we can’t assign it with their actual user id.

When they click “log in” from the menu on any page, their visitor user ID is saved as a URL param and then retrieved after they log in. This can be used to find the same shopping cart again after they’ve logged in and update the user to the logged-in user.

I have not. My background is in software engineering so I’m trying to avoid the crutch of “doing it with code” unless I know that there’s not a way to do it in Bubble. For me, I could do everything in code but then I wouldn’t be learning Bubble.

I’m fixing to push a plugin just for you. Append without reload

@brenton.strine I recommend the “URL Modifier + Parameters” plugin. It works great for URL manipulation.

1 Like

It’s $10 bucks and who knows if it reloads or not. I just published a free one that will do the job you need @brenton.strine

2 Likes

Conclusion: there is no “Bubble way” to do this. You can do it by:

  • Using Javascript via the Toolbox Plugin > Run Javascript action.
  • Using the “URL Modifier + Parameters” plugin recommended above
  • Using the Append Parameter to URL built by @doug.burden specifically to answer this question (thanks Doug!!!)
2 Likes

Hi @doug.burden and thanks for your plugin it almost helped me solve my problem. The last issue I have is when I want to add multiple parameters… It gives me 2 parameters but with “?” instead of “&” to split them, wich doesn’t work for me… I’ve tried by putting to appen element on the page as well as adding another step on my wf with only one element, with the same result unfortunatly… Thanks a lot

I’ll fix

2 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.