In 2010, when Ariela Ross seized the mayorship of Jerusalem’s al-Aqsa Mosque on Foursquare—a smartphone app that allows users to broadcast their location to followers with a tap on the screen, known as a “check-in”—the company was eighteen months old. Foursquare had a practical application: making it easier for friends to find one another. But the real hook for its devotees was its virtual merit badges, mayorships (awarded to the user who checked in the most at any given location), and leaderboards. Dennis Crowley, who co-founded Foursquare after his earlier location app, Dodgeball, was purchased by Google and quickly foundered, had a hunch that transplanting the reward system of videogames into the real world would give his new venture more stickiness. He was right. Bodegas, bars, dorms, and even street corners quickly became the scenes of pitched battles for mayoral supremacy. Before long, Foursquare was being compared to platforms such as Facebook and Twitter. Crowley and his co-founder, Naveen Selvadurai, appeared in a Gap campaign_._

View more

Such success was short-lived. By 2012, even Ross—who at the peak of her Foursquare mania held more than forty mayorships around Jerusalem, many for locations, such as the Damascus Gate, that she had added to the platform herself—had moved on. As growth levelled off, the exuberant comparisons to Facebook began to seem wildly overblown. (Foursquare now has some fifty million monthly users, compared to Facebook’s nearly two billion.) By 2013, the data-research firm PrivCo was confidently predicting that Foursquare wouldn’t survive the year. But Foursquare did survive, albeit as a relatively small enterprise; its C.E.O., Jeff Glueck, recently declared that the company would generate a hundred million dollars annually within two years. Its unlikely survival can be attributed not to what Foursquare delivers to users—the revenue from its three consumer apps, Swarm, City Guide, and Marsbot, remains modest—but to what users have been delivering to Foursquare. Shortly after he joined the company, in 2012, Foursquare’s president, Steven Rosenblatt, stumbled upon an insight many consumer-technology companies were having around the same time: that the user data it had been scooping up for years, carefully sifted and repackaged, was exceedingly valuable to marketers. “The more I started to get under the hood, the more I was like, ‘I don't know if you guys have realized it but you’re actually sitting on a tremendous amount of gold,’ ” Rosenblatt said. Ben Horowitz, a co-founder of Andreessen Horowitz, who sits on Foursquare’s board, agreed. “I said, ‘I swear to God, there’s ten million dollars a year you can just scrape off the ground,’ ” he recalled.

Foursquare’s stockpile of location-data breadcrumbs has allowed the company to steadily augment its map of the world, and to test the fuzzy signals it receives from users’ phones (the service gleans from G.P.S., Wi-Fi, and Bluetooth, and from other markers) against the eleven billion definitive check-ins provided by its users over the past seven years. According to Mike Boland, a chief analyst at the market-research firm BIA/Kelsey, Foursquare can now pinpoint a phone’s location with an accuracy that matches, and may in some cases surpass, that of much larger rivals. “Facebook has a much larger sample of data points,” he said, but “Foursquare has more accurate and reliable data.” Fourquare says its map now includes more than a hundred million locations, many of them in tightly crowded areas, like office buildings and malls, that other services still struggle to identify. “Knowing that we’re on the tenth floor versus the Equinox downstairs is a really difficult thing,” Rosenblatt told me recently, at the company’s headquarters, in SoHo. “I go to work here, but I don’t go to Equinox.” He added, “I should.” The accuracy of Foursquare’s Places database has led more than a hundred thousand other apps and developers—including Snapchat, Twitter, Pinterest, Uber, and Microsoft—to use its application programming interface (A.P.I.) to power their own features. Meanwhile, Foursquare gets access to some of those companies’ data in return, using it to further enhance its picture of the world.

Foursquare likes to show off its data-crunching prowess with predictions. It forecast the sales figures for the iPhone 6s and 6s Plus, for instance, and the decline in revenue, almost to the burrito bowl, for Chipotle following the E. coli mess. The company currently derives ninety per cent of its revenue from allowing a variety of businesses to use not just its A.P.I. but its data, too. In February, 2016, Foursquare unveiled a product designed to help companies measure how effectively a given ad campaign is driving foot traffic.* Another feature allows brands to enlist Foursquare’s assistance in targeting audiences based on their location histories. Meanwhile, Crowley, who ceded the C.E.O. role to Glueck, in early 2016, has turned his attention to developing a feature called Pilgrim, which he describes as a “context engine.” Operating in the background, it regularly beams a user’s coördinates to Foursquare’s servers, allowing its apps to “tap you on the shoulder”—or, maybe someday, to whisper in your AirPods—with recommendations based on your individual wanderings. This week, the company released a software-development kit, or S.D.K., designed to make Pilgrim the “plumbing,” as Crowley told me, for other companies that want to add location-based features to their own products. “Apps and games will change based on where you use them and where your phone has been,” he said. “So your exercise app will behave differently if you’ve been to McDonald’s a lot.”

Of course, the same software that knows which fast-food joints we’ve been to also knows which houses of worship we frequent, which psychotherapists’ offices we go to, which divorce attorneys, gun shops, and abortion providers we visit. Foursquare says it’s scrupulous about protecting user privacy, that users’ location trails are not shared with partners, and that every bit of data passed back and forth is “anonymized” (meaning that identifying details are stripped away) and “aggregated” (meaning that an advertiser can target a narrow audience but not an individual). But, as we have known for years, it’s a simple matter to tie even a small amount of anonymized location data to an actual person. A 2013 study determined that ninety-five per cent of individuals could be positively identified based on just four locations they’d visited. “Just show me where your phone is between midnight and eight o’clock, and I’ve pretty much figured out who you are,” one veteran location-data analyst told me. “There’s no such thing as anonymized data,” the technology writer Clay Shirky, Crowley’s former professor at N.Y.U. and a mentor from his Dodgeball days, agreed. “There’s only useful and non-useful data.” At the moment, individualized data isn’t that useful to marketers. But that could easily change, especially for those peddling big-ticket items. Moreover, Foursquare’s user information is now its most desirable asset, and would be acquired by a third party if the company were sold.

According to one 2015 study, nearly half of iOS apps and a third of Android apps were sharing user-location data with a third party. Google and Facebook also keep tabs on users’ locations; so do mobile-phone carriers and Uber, which weathered a scandal in 2014 when Forbes revealed that staffers had access to a “God view” allowing them to snoop on users’ location histories. Meanwhile, numerous apps feed location data to an ecosystem of other companies. Evidence suggests that most consumers haven’t yet caught on; sixty-three per cent of smartphone users surveyed said they would be “very upset” if their location were shared with an advertiser.

Ariela Ross isn’t among them. Although she hasn’t used Foursquare for years, she told me recently that she didn’t mind sharing her own location with companies “if it makes my life better and more efficient.” Industry experts believe most of us will take the same view, if we haven’t already. “It’s happening,” Albert Wenger, a Foursquare board member, said. “So to try and limit that is the wrong idea. I think what you want is an open playing field for innovation.” In a telling marketing shift, Wenger and other Foursquare boosters have recently taken to heralding the company’s modest size as a selling point, especially for partners wary of basing their survival on the benevolence of Facebook and other Web behemoths. “You don’t want to live in a world where three or four companies have all the location data,” Wenger said. “That would be a very, very bad world.”

* An earlier version of this story misstated the date when Foursquare released its tool that measures ad-campaign effectiveness.