Companies use two main techniques - cookies and web beacons - to track how you are using their web page (and other web pages) . You have seen this yourself when you visit a site, like google, search for something then get an advert for that on a different site, like Facebook or Instagram.
Website cookies are text files containing small amounts of data that are created when you open a web page. They are used to tailor the experience of using a specific website to a certain user.
Cookies can track which pages you visited on a site, the IP address and general location of your device, and sometimes login information. In the UK companies must tell you they are using cookies and ask your permission (thats why you get those "cookie banners" on a lot of sites)
Web Beacons are sometimes called tracking pixels. They are a tiny (1 pixel x 1 pixel) graphic that is placed on a website or in an email. The graphic is often transparent. They track the IP address of the computer that opened the image, the time it was viewed and for how long, the type of browser that opened it and any cookie values from other visits.
Together these technologies let companies work out what you are interested in and send you adverts on that topic to get you to spend more money with them.
How Cookies Track you.
Tracking Pixels (web beacons) explained