Considering example of Facebook, how do they get to know that which websites I have visited while I was off facebook?
I mean, how do they track, I’ve heard a little bit about Facebook Pixel, FB Like button etc… which helps them do that, but even though how do they get to know that I had visited the website?
Any time a website embeds code from another website, the website with embedded code can track the user on your website.
So if you go to a web page with a facebook share button, facebook know you were on that site.
Why do you think that Google offer Fonts, Analytics and Tag Manager? These are things that you will embed on your own website to let google track your users.
Yes, every eCommerce website and social media website using embeds code to track the user ie from where user clicks the button and in which he/she redirect.