A Chipotle Mexican Grill restaurant in San Francisco. Thomson Reuters Chipotle on Tuesday reported its first quarterly loss, along with a massive decline in sales.

Comparable-store sales, or sales at locations open for at least one year, fell nearly 30%.

The fact that Chipotle is suffering is not a surprise. Cases of E. coli last year were linked to some of the restaurant's locations in 14 states, and a federal criminal investigation is being carried out in relation to a norovirus outbreak in California.

But most investors were still caught off guard by the scale of the drop in same-store sales. Chipotle shares slid 6% on Wednesday.

Not everyone was surprised, however.

It turns out that the decline was accurately predicted by Foursquare, the social-media app that has its users "check in" to tell their friends what they are up to. The company calls itself a "location intelligence" provider, because it turns out those check-ins are much more than just millennial chatter.

On April 12, Jeff Glueck, the CEO of Foursquare, published a post on Medium predicting that Chipotle's first-quarter sales would be down nearly 30%. That was based on foot-traffic stats built from explicit check-ins and implicit visits from Foursquare and Swarm app users who enable background location.

It isn't the first time Foursquare has had this kind of success predicting sales. In September of last year, it looked into foot traffic at Apple stores leading up to the launch of the iPhone 5, the iPhone 5s, and the iPhone 6, predicting that Apple would sell 13 million to 15 million iPhones over a weekend. The number came in at 13 million.

Foursquare offers this data through a tool called Place Insights, and it counts retailers, brands, and analysts among its clients. The cost of access to this data depends on the depth of the data required.

The service offered by Foursquare, and its accuracy, is further evidence of the growing use of what is known as alternative data on Wall Street.

This is a business in which obscure data sets can be turned into tradable information. It's a cottage industry of tech firms that have sprung up in recent years, processing information on everything from the weather to web searches to location data and selling it for thousands of dollars to hedge funds looking for any advantage they can get.

"There is a whole class of emerging data, and that comes from the deployment of million of sensors around the world by governments, companies or consumers," Adam Broun, chief operating officer at Kensho, a startup in the field that is backed by Goldman Sachs, told Business Insider last year.

Fundamental and quantitative funds have zoned in on this kind of data, along with so-called quantamental funds, which mix quant approaches with bottom-up analysis.

They typically license data and crunch it using their own internals teams, pay for analysis crunched by third parties, or gather the data themselves. The slide below, from a white paper on alternative data published by Integrity Research Associates and written by Gene Ekster, sets out the process.

Ekster, who has worked with alternative data at companies including 1010data and Point72 Asset Management, told Business Insider last year that this kind of data would eventually go mainstream.

"At some point this isn't going to be alternative data anymore," Ekster said.