In its most brazen form, it works like this: Retailers read the cookies kept on your browser or glean information from your past purchase history when you are logged into a site. That gives them a sense of what you search for and buy, how much you paid for it, and whether you might be willing and able to spend more.
They alter their prices or offers accordingly. Consumers - in the few cases they recognize it is going on, by shopping in two browsers simultaneously, for instance - tend to go apoplectic. But the practice is perfectly legal, and increasingly common - pervasive, even, for some products.
Shop smart. Shop anonymously. Shop in several browsers. Be wary of prices that all of a sudden seem to have risen for no reason. This is why they want to track your purchases and where you go and what you do.