Most browsers allow you to delete cookies on exit. And there are add-ons (or built-in settings) which allow you to block tracker (third-party) cookies.
If you use the delete cookies on exit option, you can normally put in exceptions for sites you frequent (like this one.)
And of course, don't log on to anything until you actually need to. A good example is Amazon. I search for whatever I'm interested in, be it for me, for a friend, or just out of curiosity. But I don't get 1,000 ads for whatever stupid thing I searched for. It can't remember me because I'm not logged in, I block trackers and I clear cookies on exit. I'm like a random new user each time.
Another great experiment is to open YouTube without logging on, having cleared cookies and blocked trackers. The algorithm has no way to spoon-feed you content it thinks will "engage" you. So it feeds you all the most popular stuff, hoping some of it will take.
A word of caution: It will really shake your faith in humanity to see what the algorithm has calculated the average human is interested in.