Giving an update on this, in the end we could not go with the AP.getLocation()
method unfortunately. The problem is that if the user is not yet logged in or registered in the support portal, the query parameter gets lost while they go through the login/registration process.
I have also tried to register a service worker for cross-window communication. Unfortunately browsers seem to forbid registering service workers in third-party iframes when third-party cookies are disabled.
In the end I think we will have to go with a localStorage value. For Safari and other browsers in the future we will have to use the Storage Access API. Unfortunately, access to that API is currently blocked in the iframe sandbox of Connect apps (see Support of Storage Access API by Atlassian Connect), so we hope that it will be enabled again soon.