Great article for explaining these things.
Web tracking is mainly performed by monitoring IP addresses, and using techniques such as cookies, or the more powerful supercookies
Some sites, such as those belonging to advertising companies, use third-party cookies to track a user across multiple sites. In particular, an advertising company can track a user across all pages where it has placed advertising images or web bugs. Knowledge of the pages visited by a user allows the advertising company to target advertising at the users presumed preferences.
Another study shows that not only are these third-parties increasing their tracking of users, but that they can now link these traces with identities and personal information via online social networks . In , a behavioural targeting study was performed on an e-commerce site for a clothing line. The results for the analysed case showed that the web site contained a total of nine tracking tags that linked to eight third-party companies.