Curious about which country OP is in and which payment method was used.
I'm in Australia, and find when I pay by credit card, this same thing happens to me where I get ads for medicines related to precription medicine I've just purchased.
When I use cash however, I don't get the ads, so my best bet is that it's the credit card that's used to match the purchase to me in this scenario.