Companies on the Internet can collect information about you any time you are online.
Usually you have several browser windows open. You are logged into facebook or google in one window and browsing in another window.
These advertising sites will know what you are looking at and link it to your profile. Even if you are not logged into any sites while you are browsing, they can track your browsing and link it up later when you login.
Many of these companies provide ways to see what they know about you and remove some of the data. They also allow you to opt out of some of the tracking. For google they provide a dashboard where you can see a high level view of the information that they know about you: https://www.google.com/settings/dashboard.
Google also provides a link to find out some of what ads report about you. This is usually your age range and gender: http://www.google.com/settings/ads/.
A good way to manage what Internet companies know about you is to use the private browsing feature of your web browser. This limits the data that is kept for that session of browsing.
It is important to understand much of what you do online is tracked.
You can take steps to make it more difficult to track you by using Virtual Private Network (VPN) and private browsing, but you will have to avoid logging in to any of your accounts or you will no longer be anonymous.
