I'm giving promotions to users who sends us other visitors. This is done on the client side.
I can do this using dynamic GET parameters, e.g. http://www.mysite.com?app_source=user_id
or I can do this using the hash, e.g. http://www.mysite.com#app_source,user_id
.
Are there any pros and cons for any of these methods?
The standard way to do this for a GET request would be to simply use a query string.
http://www.mysite.com?app_source=user_id
If you use a URL anchor such as
http://www.mysite.com#app_source,user_id
The anchor portion (#app_source,user_id
) is not sent to the server
For example, see this related question.
Here's another related question
The anchor is merely a client-side flag to tell the browser where to navigate on the page.
To address your redirect concerns, you can process the query string before redirecting, add/remove and key/value pairs you want, and then redirect.
PHP gives you direct access to the query string with $_SERVER['QUERY_STRING']
Rails uses request.uri
which you can parse
Also, when you see fanciful things like facebook.com/#stuff
, the anchor portion is handled with client-side javascript. So you can do this, but you'll be writing ajax code that is sending normal GET requests like the one recommended at the top of this answer.
Why add complexity? Do you just like the look of the #
better than the ?
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With