Some of the ads are contracted – ie companies buying the space directly from us.
Some of the ads are retargeted – ie they operate based on your browsing history (pop over to John Lewis* website, browse through the lingerie section then come back here and see what happens)
Some of the ads are contextual – ie they display campaigns relevant to bought keywords that are found in the body of the page. So if you talk about a topic often you quickly see ads based on that topic.
*John Lewis may or may not be still participating in a retargeting ad campaign. If they aren’t then try The Trainline website or Halfords.. Those are some I can think of off the top of my head.
Of course, for £1.49 you get to turn off all the ads and have the site work much faster for you 🙂