Dennis Crowley thought his 13-year dream might never come true.

Crowley is the founder of Foursquare, the seminal social networking service that broadcasts your location across the net and serves you tips and deals based on where you are. This past February, the New-York-based startup boasted 40 million registered users, but it was facing competition from countless others – including the mighty Facebook – and as far as Crowley was concerned, his service had never worked as it should. Rather than automatically sending users tips as they moved from place to place, the Foursquare smartphone app required them to "check in" every time they wanted information about their location – a time-consuming process that rewarded sitting still rather than exploring and discovering new experiences.

>Crowley always envisioned Foursquare as a fellow traveler, dispensing relevant information unbidden – sale items as you entered a boutique or popular appetizers as you sat down at a new restaurant

Crowley always envisioned Foursquare as a fellow traveler, dispensing relevant information unbidden – alerting you to tucked-away bars as you strolled a neighborhood, sale items as you entered a boutique, or popular appetizers as you sat down for dinner at a new restaurant. But time and again, he was stymied by the massive technical challenge of building this kind of system. "I was worried it wasn’t going to work forever," Crowley says.

Finally, after 13 years of trying, Crowley has cracked the problem, thanks to a wonderfully clever data hack from two big thinkers on the payroll: lead engineer Anoop Ranganath1 and data scientist Blake Shaw. A new version of Foursquare began to roll out this fall, offering the kind of "passive notifications" Crowley had always dreamed of, and last week, with the release of a new app for iPhone and iPad, it reached out to an even wider audience. According to the company, users interact with the new app 60 percent more frequently than they did on previous versions, and they spend 30 percent more time with the thing. Of the more than 1 million "pings" sent in the first two months of the new service, about 40 percent were at least opened by the Foursquare faithful.

The trouble is that, over the intervening years, other companies have begun to have the same dream as Crowley. App stores are crawling with similar services. Silicon Valley venture capitalists have pumped tons of money into location apps. And then there's Facebook, whose social networking service is a mainstay for hundreds of millions of people across the globe. But now that his app is working as he first envisioned 13 years ago, Crowley is unbowed.

"There's going to be 100 million people that carry software in their pocket, [and] everywhere you go it's going to tell you about stuff that you normally wouldn't have known," he says. "I think that stuff is going to be built by Foursquare."

Anoop Ranganath and Blake Shaw. The pair debugged the new version of Foursquare by taking walks around the city.

Engineer Meets Data Scientist —————————–

It all began when engineer Anoop Ranganath sat down for a chat with data scientist Blake Shaw.

In January, Ranganath took on the task of building a prototype for a new Foursquare app. By the spring, even he had to admit that the project was a mess. It caused batteries to drain after just a few hours. It gave bad directions. It sent alerts at the wrong times – tossing users recommendations for a nearby fashion boutique when they were comfortably seated at a bar around the corner.

The problem was the method the prototype was using to identify location – a straightforward combination of GPS, Wi-Fi signals, and cell towers. It couldn't always find the right signals, and even if it did, it tended to seriously drain the battery as it searched.

But when Ranganath told Shaw about the problems, the data scientist had an idea. Why not take a shortcut? Foursquare already had a massive database of check-ins – location information about the places its users most liked to go. And this data didn't just include the place where someone had checked in. It showed how strong the GPS signal was at the time, how strong each surrounding Wi-Fi hotspot signal was, what local cell towers were nearby, and so on. Leveraging this data meant that Foursquare could still grab a good current location even if users were underground, near a source of radio interference, or facing some other signal obstacle. Chances are, some prior Foursquare user had seen the world through the same flawed eyes and reported his or her location.

"It's one thing for us to match one point to another point, but we have a lot more options when we can match a cloud of points to another cloud of points," Ranganath says. "It was very much an ah-ha moment for everybody."

Blake Shaw. Photo: John Francis Peters/WIRED

Foursquare's ability to cut through the noise of crowded cities didn't only help the company locate its users. It also reduced battery drain. Suddenly, the app didn’t need to activate the phone’s radios nearly as often. Instead, it could use a technique called "geofencing," telling the operating system that it didn’t need to check anything unless the phone crossed certain geographic boundaries. Before, those boundaries had been fuzzy and hard to set, so Foursquare had to stay awake more often. Now, those boundaries were clear, and Foursquare could sleep for long stretches, waking up to look around only on occasion. "We realized we can build probabilistic maps of how your phone sees the world," Shaw says.

When Programmers Get Exercise —————————–

Despite all the high tech, Foursquare’s system needed refining, and for the development team, that meant many a walk around New York and San Francisco, where Foursquare’s engineers are based. Crowley tested the system too, and provided a key insight that helped make the recommendation system far less annoying: Only poke people with tips when they are in unfamiliar locations – traveling to a new city, for example, or visiting a new restaurant where their friends have left advice.

Whether the new Foursquare is as useful to the general public as it has been for its initial testers remains to be seen. But in the wake of last week's launch, Crowley is still aiming for his magic number: 100 million users.

>Only poke people with tips when they are in unfamiliar locations – traveling to a new city, for example, or visiting a new restaurant

Others don't quite see the app in the same light. Ben Lerer, CEO of Thrillist Media Group, a publisher of local online entertainment guides, says that while the new passive notification system "has been awesome" in his personal experience – accurate, relevant, and unobtrusive – he's not sure it will be a game changer for the company.

"It’s a really compelling technology that [could] help them get bought by Google or Facebook or somebody else," he says. But he doesn't think the tool "will explode their numbers."

Some people even question whether this sort of app is really the future. Mike Krieger – the co-founder of the Facebook-owned photo-sharing service Instagram, which began as a Foursquare "check-in" competitor – believes it makes more sense for location services to be part of larger applications that do far more than just track your whereabouts. "Location is as important as ever," he says, "but leading with it doesn't seem to be something that people have really gone for."

Certainly, the days when people used Foursquare just to check-in – just to show everyone on the net where they were – have long since passed. But for Crowley, that's a welcome thing. "You really had to know how to use Foursquare to get all the value out of it," he says. "The best version of Foursquare is the one that you don't have to remember to use."

Crowley's engineers agree. But for the moment, they're just happy they've built what they set out to build.

"This is something we’ve been wanting to do since the beginning, just kind of waiting for the technology to catch up," Ranganath says. "Now, the big surprise is that we’re here."

The Foursquare offices in New York. Photo: John Francis Peters/WIRED

1 Correction 11:30 EST 12/09/13: An earlier version of this story incorrectly spelled Anoop Ranganath's name.