In urban areas, where the only source of coffee in waterways is urine, your cup of Joe could be a red flag of contamination by human excrement.

How many cups of coffee have you had today? A new study finds that your caffeine habit could provide a red flag to alert authorities of sewer leaks and overflows.

About 3 percent of caffeine from coffee, chocolate, tea and energy drinks ends up in the sewer system, excreted through human urine. In urban areas where the only source of caffeine is human urine, high levels of the compound in rivers or other bodies of water (where human urine and feces should not be present) are signs of contamination by fecal coliform bacteria, the new research finds.

"If fecal coliforms come from human sewage, they will come with caffeine," study researcher Sébastien Sauvé, an environmental chemist at the University of Montreal, told LiveScience. "So if we find caffeine, that means it came from sanitary contamination."

Having caffeine as a marker of contamination is important, Sauvé said, because fecal coliform bacteria can also make its way into waterways via the feces of cats, dogs and wild animals. Leftover caffeine tells wastewater experts they have a problem with the sewer system rather than simply too many geese by the river. [10 Deadly Diseases that Hopped Across Species]

Caffeine in the water

Sauvé and his colleagues took 120 water samples on the Island of Montreal in June and October 2008, both during dry and wet weather each of those months. Like many municipal water systems, part of Montreal's is a combined system in which human sewage and rain run-off end up in the same place, Sauvé said. When it rains too much, raw sewage can overflow into waterways.

"What people sometimes forget is if the system is overflowing it's not overflowing at the wastewater treatment plant, it's overflowing from everywhere," Sauvé said. "It's not a good idea having it overflowing in the river, but it still is better than overflowing in the basements of people's [homes]."

Fecal coliforms aren't always easy to analyze, so Sauvé and his colleagues were searching for other compounds that might stand in as a red flag that these nasty bacteria are present. They tested for two compounds, caffeine and carbamazepine, an anti-seizure medication that is an appealing marker because it degrades very slowly in the environment.

Sewer problems

The analysis revealed that carbamazepine and fecal coliform counts weren't linked, perhaps because the drug is taken by relatively few people, Sauvé said. In contrast, he said, "it's probably very difficult to find one home or two homes where there isn't one person taking coffee, tea, Coke, chocolate, or some medication that contains caffeine or energy drinks."

Sure enough, the researchers found that if caffeine appeared in the water at levels of 400 nanograms per liter — about the equivalent of four cups of coffee dumped into an Olympic-size swimming pool — levels of fecal coliform were always above 200 colony-forming units per 100 milliliters of water. That's the level that Canada has set as unsafe for humans to swim or bathe in. In the U.S., the Environmental Protection Agency considers 235 colony-forming units per 100 milliliters to be unsafe.

Caffeine wasn't a perfect marker for fecal coliform, Sauvé said. Sometimes, water with lower or nonexistent levels of caffeine is still contaminated, possibly from wildlife feces. But the caffeine marker could be used to figure out when sewer repairs are necessary, he said.

"If there is fecal coliform that comes from ducks, you still don't want to go and bathe in that lake or pond," Sauvé said. "But in terms of what needs to be done, if it's cross-connected sewers and you find a lot of caffeine it means that the sewage system isn't put into place properly and you need to find out where the problem is."

The researchers reported their work online Nov. 8 in the journal Chemosphere.

You can follow LiveScience senior writer Stephanie Pappas on Twitter @sipappas. Follow LiveScience for the latest in science news and discoveries on Twitter @livescience and on Facebook.