Creating custom JS triggered on page load

I want to check for the availability of a key generated from the URL after authenticating with Google on page load called 'txtPublicToken'. Once this key is included in the URL/captured, I want to trigger the action of including it in an API request for completing authentication. What would be the suggested method doing so? Custom on page load JS? We are doing this method to work properly with

You can check the following box:
Screenshot 2023-09-20 at 9.04.10 AM

In the JS you can look at the URL Params using an if statement
Screenshot 2023-09-20 at 9.06.12 AM
Screenshot 2023-09-20 at 9.06.05 AM