HTTP Query String vs URL Parameter for referral codes

http-requestlaravelrouting

I'm working with a Laravel app and am development a "referral" feature. A user clicks "refer friend" and a URL pops up that can be shared on Facebook etc, when another user clicks on the link they are taken to the site, a session parameter is set, and later if the user signs up, the original user gets credit.

There are two ways to accomplish this. a query string www.example.com?invite=123 or routing parameter www.example.com/invite/123

As I was reading this answer https://softwareengineering.stackexchange.com/questions/270898/designing-a-rest-api-by-uri-vs-query-string/285724#285724 I seemed to get the idea that query strings are useful for non-hierarchical data. This is how sites such as Copy.com work with their rerrals.

But looking at other examples on the internet, for example DropBox, Lyft, Hulu, Uber and others use route parameters (more seem to use route parameters than query parameters).

A query string is more cumbersome or confusing verbally tell someone or to write down on paper (and less visually appealing), but it also makes site previews easier when sharing on Facebook (no need to dynamically generate og:image tags etc each time the URL and code are parsed)

Is one really more correct than another? Is there a standard for this or is it all preference?

EDIT: Do either of these options affect SEO? For example would www.example.com/invite/123 rate differently than www.example.com?invite=123 when a page is crawled containing either of these links?

Best Answer

This form

www.example.com/invite/123

is preferable when your URL refers to something concrete and specific, like a business entity, transaction or document. The word "invite" typically refers to a controller method.

This form

www.example.com?invite=123

is preferable when you want to modify the operation or resource at the designated URL using parameters. For example, the URL for a search page might look like this:

www.example.com/search?term="flargle"&orderby="date"
Related Topic