added to the Site Administration > Appearance > Additional HTML page. This would enable it to run on every page load of your Moodle site so that it didn't matter what URL the user comes from or arrives to.
Each time a page on your Moodle site loads, the script would analyze the URL to check if the referrer URL contains the parameter you are looking for. If it finds it, it would save that information to a cookie (or local storage) making it available for use on the registration page.
So why go through all this when you could just have the script just check the URL of the registration page? Because chances are that the user won't be arriving directly to the registration page. In fact, you would most likely want to refer them to a course page which would lead them to the registration page by which time the special URL parameter would be lost. Even if they arrive on the registration page directly, they could easily decide to browse around your site first (I would). Therefore, it is probably best to capture that special URL parameter from any point of entry.
The example on following page talks about WordPress but it should be possible to use the information as a starting point and adapt some of it for use in Moodle.
You might be find other similar examples by googling for it.
The information on the following page will be useful to check the URL parameters for your special one:
I wish that I could just give you the code but it is all just conceptual at this point and needs to be developed. Hope you find it helpful.