SAN FRANCISCO — Once, only hairdressers and bartenders knew people’s secrets.

Now, smartphones know everything — where people go, what they search for, what they buy, what they do for fun and when they go to bed. That is why advertisers, and tech companies like Google and Facebook, are finding new, sophisticated ways to track people on their phones and reach them with individualized, hypertargeted ads. And they are doing it without cookies, those tiny bits of code that follow users around the Internet, because cookies don’t work on mobile devices.

Privacy advocates fear that consumers do not realize just how much of their private information is on their phones and how much is made vulnerable simply by downloading and using apps, searching the mobile Web or even just going about daily life with a phone in your pocket. And this new focus on tracking users through their devices and online habits comes against the backdrop of a spirited public debate on privacy and government surveillance.

On Wednesday, the National Security Agency confirmed it had collected data from cellphone towers in 2010 and 2011 to locate Americans’ cellphones, though it said it never used the information.

“People don’t understand tracking, whether it’s on the browser or mobile device, and don’t have any visibility into the practices going on,” said Jennifer King, who studies privacy at the University of California, Berkeley and has advised the Federal Trade Commission on mobile tracking. “Even as a tech professional, it’s often hard to disentangle what’s happening.”