What you're describing used to be called contextual advertising which worked perfectly fine based on the content of the page user views.
It just wasn't bringing all the excess profits that advertising corporations wanted. So, enter the fingerprinting and tracking. Like a stalker following you around the web, gathering data on what you are and what you might want to buy.