The ad you are referring to on appear based on each user's recent web browsing history.

For example, you might see an ad for Kraft if you had recently been searching recipes or cooking websites. Or, if someone else is viewing a sports website, she might see ads for sports-related companies.