One concept that you have to understand is that all FAGMANS accounts are linked, there is no difference to the interested agents between your Facebook, and Amazon account, they are all linked to you. Most social media and other apps, services etc, require your phone number or email. Have you used a different one for each?
The first step is the identification of demographics. >Pic related about a campaign Signal led on facbeook and Instagram (facebook owned) where they showed people directed ads based on facebook's cathegorization. Countrary to what people believe, these ads do not find out information about you. The ads are created and sent for a specific target. Facebook knows you are a pregnant woman with an interest in fitness, but the advertiser merely sends out an ad to pregnant women who have an interest in fitness.
How this is done is dependent on the site. Facebook has groups. What those groups are about is reported by the users through tags, in the interest of being found by people who want to be a part of a sports group. Then, you go and join those groups. Depending on your interest, which is calculated based on your constancy of participation, your interest is ranked. You have a set of interests derivated likely from group belonging, as well as likes and other mechanisms. Instagram does this mostly through your likes. youtube obviously keeps tracks of what videos you watch. These videos have tags. You can make a weighted accumulation of all tags you've consumed: Take the amount of time you watched a video, and assign that as a weight to a tag, then add those tags together and you get: [ "puppies": 3.6, "metal": 2.4, "republican": 1.2, "democrat": -0.6, ... ]