How do friend recommendations work, probably

Ever wondered how you get eerily accurate friend recommendations for folks you’ve just met and had anything in common with them?

Three young women sitting at a TikTok themed party table eating sushi.

Ever wondered how places like Instagram, Facebook, LinkedIn give you eerily accurate friend recommendations for folks you’ve literally just met and you’ve not really had anything in common with them beforehand? There are a ton of different ways to do that, but they all involve some form of tracking.

There’s location tracking, of course. Your Facebook / Instagram / TikTok app knows where you are because they have access to your location. Even if you disabled that and you upload images or videos that do have the location exif data, the apps will extract that and infer that you were probably at the same location where the photo was taken.

They then compare this to all the other users they have on their platform, and generate a bunch of assumptions: if you and Bob were at the same place at the same time for an hour and a half, and it’s not a movie theatre or something public, then you probably attended the same event, so they tell you about Bob’s account, and perhaps you want to follow them? Fairly simple in concept, kind of hard to write good code that filters through the inaccuracies.

The other, significantly easier way is to use share IDs. Here’s a link that Instagram gives me when I click the “copy link” button: https://www.instagram.com/reel/C6peGHEgNAE/?igsh=MWt3amM4cDZmaWRwOQ== (it’s a reel about barbell back squat bar blacements), and here’s one from a YouTube video: https://youtu.be/helyO25gj_k?si=sHh9v9a28HfJeGyF (Linus from LTT reviews an HP Spectre laptop).

See those query arguments? igsh=MWt3amM4cDZmaWRwOQ== and si=sHh9v9a28HfJeGyF. They probably stand for Instagram shareID, and just shareID.

First one is probably a base64 encoded string judging by the last two == there. Decoding it gives me 1kwjc8p6fidp9, which is valid, but also non-specific. It’s just an ID. YouTube’s is just an ID. But the important bit is how they work.

When you click the “copy link” button, the app generates a random identifier, and associates it with a bunch of data:

  • your account
  • which reel / post / video / photo you’re sharing (though that one is in the rest of the link)
  • what device you’re on
  • what time it is
  • where in the world you are (location)

When you send that link to Bob and they click on it, the service will know that Bob clicked a link which had that share ID, which means it was sent from you, they opened it within a minute, you two live like 2000 miles away, both of you are on mobile devices, which probably means you’re already connected some other way and it’s not a work thing, and both of you are interested in gym stuff. Or IT stuff. So it stands to reason that the two of you should be connected, and they appear in your recommended accounts to follow.

Now the really fun thing is that this tracking doesn’t even need to happen within Instagram / YouTube. Because these services are either owned by the same entity, like Google / YouTube and then Instagram / WhatsApp / Meta, they most probably share user data on some level already. If not directly, due to the privacy laws in Europe (hopefully at least), then diagnostic / tracking data. It’s also probably safe to assume that the Google / Meta pair also exchange some diagnostic and tracking information for mutual benefit (to them).

Which also means that if you’re on a random site that has Google Analytics, or Meta’s Facebook pixel or some other form of tracking thing installed, then your activity also gets funneled up to these companies. Pattern recognition is important: if you go to a bunch of sites, read articles, look at their shop, then go to your messaging app, and then Bob goes through roughly the same activity not long after, and this repetition occurs many times between you and Bob, they will make the connection that the two of you have something in common, and an account follow will be offered.

Thinking it one step further, because they already know that Bob’s into woodworking, and they follow these 6 woodworking accounts that you aren’t, because you and Bob probably have similar in interests as well, you’ll get recommendations to follow those 6 woodworking accounts too! And you will, because chances are you and Bob are more alike than you think, and because there’ll be social proof: look, Bob already follows those accounts!

There’s no real point to this article besides “huh, interesting, today I learned” in case you were curious. I also don’t know how they work exactly because I never worked on any similar technologies, but this is how I would implement them from a very naive starting point.

You can always strip the ?si= parts of the links out before sending it to others. It’s a bit more work on your end, and I’m fairly certain there are browser extensions that already do this, but I’m yet to find one for a mobile device.

Photo by Evgeniy Alyoshin on Unsplash