55

This is probably something obvious that I just haven't noticed, but how does SO know who shared a link to a post?

The Announcer, Booster, and Publicist badges all seem to be able to track who shared the link.

2
  • 3
    I've wondered for a long time why there is a constant number at the end of every share link, until I found out it is my userid which led me to realize that they're using it to track the number of visits for this purpose..
    – T J
    Oct 18, 2014 at 15:33
  • 1
    Related meta.SE question.
    – Air
    Oct 20, 2014 at 15:55

1 Answer 1

86

The share link includes your userid. My share link for your question is:

http://meta.stackoverflow.com/q/274712/100297
#                               ------ ^^^^^^

274712 is the question id, 100297 is my userid on Stack Overflow and Meta Stack Overflow.

Answers have similar links; the id for this answer is 274713, so the share link for this answer, customised for me, is:

http://meta.stackoverflow.com/a/274713/100297

The only difference then with the question link is that the URL path starts with /a instead of /q.

Both link types then redirect to the full question or answer URLs:

$ curl -s -D - -o /dev/null http://meta.stackoverflow.com/q/274712/100297 | grep Location
Location: http://meta.stackoverflow.com/questions/274712/how-does-the-announcer-badge-and-similar-badges-know-who-shared-the-link
$ curl -s -D - -o /dev/null http://meta.stackoverflow.com/a/274713/100297 | grep Location
Location: http://meta.stackoverflow.com/questions/274712/how-does-the-announcer-badge-and-similar-badges-know-who-shared-the-link/274713#274713

The site knows what question an answer belongs to, so the URL for an answer is the same as for the parent question but with /<answerid>#<answerid> tacked onto the end.

6
  • 6
    Oh. Duh. For whatever reason I though that the second half would be the answer on the question. This makes a lot of sense, though.
    – Pokechu22
    Oct 17, 2014 at 18:46
  • 28
    ++ finally I know how this stuff works... you need to use the SHARE instead of copy-pasting the links to get these badges...
    – user2140173
    Oct 20, 2014 at 13:54
  • How to disable sharing userid?
    – Alex78191
    Oct 27, 2017 at 17:02
  • 2
    @Alex78191: by removing the last number from the URL when you share it, manually. http://meta.stackoverflow.com/q/274712 still works too.
    – Martijn Pieters Mod
    Oct 27, 2017 at 17:03
  • It is inconvenient to delete every time.
    – Alex78191
    Oct 27, 2017 at 17:08
  • 1
    @Alex78191: Then just don't. But there are no easier ways of getting the same URL.
    – Martijn Pieters Mod
    Oct 27, 2017 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .