Query parameter clarification

Hi. I want to extract a query parameter from the current page’s url with this function - QUERY_PARAMETERS_OBJECT(url: String) => Object

what should i use as my current page or app’s url?

Thanks

If you are working on a web app, you can just define the expected query parameters as page parameters under the Variables configurator; any query parameters in the app URL loaded on web will be available as page parameters.

The current page URL should be made available as a system variable, made a ticket: https://tracker.appgyver.com/feature-requests/p/add-windowlocation-properties-as-a-system-variable-for-web

As a hacky, not-guaranteed-to-be-future-proof way, you can also use self.window inside the JavaScript node to access the window context of the current page, so e.g. self.window.location.href has the full URL.

Thanks @Harri_Sarsa. So the use case isn’t for passing a param from page to page, but for stuff like link sharing with referrer codes etc. So end user will find link on social media or anywhere and click to land on webapp and at that point we want to grab the query params and use toward attribution etc.

So only way around this right now is in the 3rd paragraph yeah?

As long as you know what the query parameter names are beforehand, you can just register page parameters for them and access them that way. E.g. if you have page param link_share_id for the page that is initially loaded in navigation, navigating to

https://myapp.appgyverapp.com?link_share_id=abc123

will result in params.link_share_id being abc123.

thanks @Harri_Sarsa will give this a shot and report back

Hi @Harri_Sarsa ,

I tried setting up page params as you recommended in an attempt to use URL parameters to set app variables, but nothing happened. I tried this on both the Global area and the default page. Any tips?

Thanks,
Ethan

UPDATED #1: I thought I figured it out. It looked like my attempt at redundancy (setting the params at the global canvas level and the default page level) somehow screwed it up. Removing them from global canvas solved the issue… on Preview.

UPDATED #2: However, when I actually build the app, the button labels are empty again. What the heck is going on?!

On my screen the labels seem to appear on the buttons for an instant but are then replaced with nothing (blank).

Hi, could you share me your app ID and the link to the built app? I’d like to check if I can see what the issue there is.

Bah, sorry, I didn’t see the notification of your reply. Honestly I have made about a million revisions to this app over the past five days and it looks nothing like this anymore :stuck_out_tongue_closed_eyes: It is definitely weird that Preview and Build were acting differently, but I discovered that once I uploaded it to my server it worked as expected. So since I made this post I have been skipping the step of testing on [myApp].appgyverapp.com and instead only A) using Preview (more frequently), or B) uploading it to my server (to test major changes). I will send you a message with the app ID and link if I notice something similar happening again though.

For other folks with similar issues: I was also having trouble working with params from the global canvas. Once I moved those to the main navigation page, it started working. So moral of the story: Avoid params on the global canvas.

1 Like