Public toilets are one of the markers of civilisation. By removing the need to wee and poo in the street, they keep our cities clean and reduce the risk of disease. We might not always like sharing a toilet space with other people, particularly if it's not very clean, but it's clearly a brilliantly useful idea.

So it should be no surprise that many wild animals also share toilet spaces. Rather than pooping randomly, many species have dedicated sites where they all defecate repeatedly. The resulting piles of faeces can be gargantuan. As you might expect, these latrines are placed at strategic locations, often away from where the animals feed and sleep.

But at this point, the story takes a turn for the strange. Human public toilets are mostly about sanitation:  they reduce the spread of disease. However, animal communal toilets seem to have almost nothing to do with health.

Oddly enough, the one group of animals that uses communal toilets for the same reason we do is otherwise quite unlike us: social insects.

The black garden ant is the first insect known to use specialised toilets

For instance, Jerdon's jumping ants build special refuse chambers in their nests, well below the living areas. They dump their faeces there, along with other waste such as uneaten food, ensuring that any harmful bacteria in the waste don't infect the ants themselves. Social spider mites have similar habits.

Other ants take a different approach. One species of leaf cutter ant dumps its waste in a pile outside the nest. That may sound sloppy, but there is a specialist group of worker ants whose only job is to deal with the waste.

None of these dumps are toilets in the strict sense, because they store many kinds of waste as well as faeces. For this reason, scientists tend to call them "middens".

The black garden ant is the first insect known to use specialised toilets: that is, places where they only deposit faeces, and no other forms of waste. It's not clear why, and it might not be to protect against disease. One possibility is that the adult ants feed the faeces to the larvae.

For animals more closely related to humans, shared toilets have other functions. Communal latrines are mostly made by mammals: that is, animals with hair. For many mammals, toilets are a social thing.

We may wrinkle our noses at the thought of smelling our poop, but for many animals, a sniff of poop or urine can convey a wealth of information. For these animals, sharing a toilet is a form of social networking. Each animal uses the unique odours in its poop or urine odours as status updates. If a brand manager was to get involved, the system might be called Faecesbook.

The entire lemur family pees and poops at the same few places

White-footed sportive lemurs, which live in southern Madagascar, absolutely rely on shared toilets to communicate.  

These lemurs live in families, but not cohesive ones. They are nocturnal, and each lemur prefers to move around independently throughout the night. Unlike most primates, males and females of the family don't groom each other. They also sleep separately, on different trees.

To stay in touch, the entire lemur family pees and poops at the same few places.

These toilets are usually a clump of trees, in the centre of their territory, away from the trees they sleep or feed in. Wherever the lemurs are, they usually keep coming back to the toilet trees to relieve themselves. Once there, they cling to the tree trunks, lift their tails up, drop faeces to the ground, and leave behind urine-stained trees with unique scents.

The male lemurs could defend their females without physically confronting the intruding males

By sniffing and licking these tree-latrines, the family members exchange information. "This may facilitate bonding between the individuals which rarely interact otherwise," says Iris Dröscher of the University of Göttingen in Germany.

Dröscher followed some of these lemurs in the wild, and found that the toilets may have another purpose. She observed that the males only placed scents from their scent glands at the toilet trees, and not anywhere else in the forest.

Moreover, when males from neighbouring territories were around, the adult male lemurs would visit the toilets more often, leaving behind scented warning messages for the intruders. In this way, the male lemurs could defend their females without physically confronting the intruding males.

For humans, accustomed to talking out loud, this may seem an odd way to communicate. But given the lemurs' lifestyle, it makes sense.

"The advantage of scent is that it is a long-lasting signal," says Dröscher. "Even after several hours other individuals will be able to detect the signal."

These toilets may be markers warning neighbouring lemur groups to stay away

A lemur could call out, signalling its precise location, but that is only a temporary signal. Besides, there are predators about, so using scents is probably a safer way for them to announce their presence.

Some other lemurs also use shared latrines. But they have other reasons for creating these toilets besides socialising, says Mitchell Irwin of Northern Illinois University in DeKalb, who reviewed the use of shared toilets in lemurs in a study published in 2004.

Irwin points out that many other primates use scents to communicate, but only four groups of distantly-related lemurs use communal latrines. These toilets, he suggested, may be a special form of scent-marking behaviour.

For instance, the southern gentle lemurs of south-east Madagascar build communal latrines at the borders of their territories. These toilets may be markers warning neighbouring lemur groups to stay away.

Some dwarf lemurs also use latrines to defend their territories. But their toilets look very different. Instead of pooping on the ground, these lemurs smear their faeces on branches of trees. They keep coming back to defecate in the same place, creating a thick build-up of the faeces on the branches.

Some bamboo lemurs also hide their poop under leaves

Other species, such as bamboo lemurs, create communal toilets around the trees where they sleep or eat. By doing this, the animals focus on defending their important resources instead of the entire territory.

Latrines can also be a way to hide. For instance, northern collared lemmings build underground toilets, and this may be a way to avoid predators. Some birds of prey can see the faeces vividly, because it glows ultraviolet, so the lemmings can protect themselves by defecating underground.

Some bamboo lemurs also hide their poop under leaves, says Irwin, suggesting that they don't want their faeces to be noticed. This could be to prevent predators from knowing where they are, but this idea hasn't been tested experimentally.

Other public toilets look a little more human. They seem to have evolved as a way for their users to avoid being infected by parasites.

For instance, red howler monkeys in the central Amazonian basin defecate in specific places that have minimal vegetation around. This prevents leaves, which they might eat as food, from getting contaminated by parasite-laden falling poop.

Most carnivores have territories they need to defend

"But that's not the same as deliberately building up latrines," says Irwin. In fact, communal toilet building seems to be the exception rather than the rule in primates.

In other mammals, communal toilets are more widespread. Take carnivores, for example.

Most carnivores have territories they need to defend. In addition to marking trees with scents from their scent glands, or scratch marks on trees, some species also use shared toilets to defend their homes.

Meerkats do this. Each group has a number of toilets near the core of their territories. But according to a study published in Animal Behaviour in 2007, each group of meerkats also has a couple of communal latrines at the boundary of its territory.

Hyenas scent-mark their territories with communal latrines

The group shares some of these latrines with neighbouring groups of meerkats. This may allow the different groups to sniff and monitor each other, without having face-to-face confrontations.

European badgers use shared latrines in a similar way. Adult males visit the boundary toilets more often during the mating season, suggesting that they also use the shared latrines to defend their groups' females.

Many other group-living carnivores use shared latrines. Hyenas scent-mark their territories with communal latrines, as do raccoon dogs and some marsupial carnivores, such as tiger quolls.

But this trait is not restricted to gregarious animals. Some solitary carnivores also use communal toilets.

The elusive ocelot or dwarf leopard of South America is one such example.

Two completely different solitary carnivore species can share latrines

Although fiercely solitary, several individual ocelots of both sexes often defecate at the same place, creating a communal latrine. These latrines then become an information centre. Female ocelots can convey if they are ready to mate, and male ocelots can advertise their presence to other males and females in the area.

Sometimes, two completely different solitary carnivore species can share latrines. In the southern part of the Andes in South America, Pampas cats and fox-like culpeos share latrines in small rocky caves. "These are not only two different species, but from different families," says Rocio Palacios, a biologist from the Andean Cat Alliance. Nobody knows why they do it.

While several carnivores build up shared toilets, this behaviour is especially common in plant-eaters.

Many herbivores do not poop where they feed. They select separate areas to defecate in, often creating massive piles of dung. Like some lemurs and most carnivores, they use these communal latrines to defend their territories, and communicate with each other.

Since rhinos have poor eyesight, they rely heavily on smells

Elephants produce massive dung piles, as do guanacos and many antelopes such as dikdiks and gazelles. It would be wise to watch your step if you are inside a wildlife reserve. Unless you are a rhinoceros.

Black rhinoceroses often tread through their own dung piles, which are known as middens, and kick the dung around. Since rhinos have poor eyesight, they rely heavily on smells. So they spend time sniffing the dung at the piles to decode messages left in them by other rhinos.

In a study published in January 2015, researchers measured how much time white rhinos spent sniffing the poop piles of stranger rhinos versus those of familiar rhinos. They found that the rhinos can tell the difference: they spent nearly a minute taking in scent-laden messages from strangers, but they sniffed dung piles of group members for less than 20 seconds.

Since most rhinos are imperilled, their dung piles help researchers keep track of them. In fact, for conservationists working with elusive or threatened species, poop is invaluable.

Faeces can be a treasure trove of information about wildlife. The teeth and hair contained inside a carnivore poop can reveal what prey the animal has eaten, says Palacios. What's more, if you study poop over the years, you can see how the animals and plants in the landscape are changing.

The communal latrine contains thousands of fossilised poops

Poop can also help us piece together the history of life on earth.

In a study published in 2013, a team of palaeontologists described the oldest fossil record of a public toilet within the Talampaya National Park in north-west Argentina. The communal latrine contains thousands of fossilised poops, and is estimated to be 240 million years old.

Poop is made up of organic material, which gets easily degraded by weather, insects and microbes. So it is rarely fossilised, says Lucas Ernesto Fiorelli of the CRILAR – CONICET in Anillaco, Argentina. But the Talampaya region contains thousands of these latrines, some with over 30,000 petrified poops.

Given the massive scale of defecation, the large size of the dungs, and the presence of fragments of wood, leaves and mosses inside them, Fiorelli's team believes that the latrines could have belonged to massive plant-eating animals. The most likely culprits are large reptile-like beasts called Dinodontosaurus, which were common in the region at the time. They looked rather like rhinos.

Elephants shape plant communities by dispersing seeds in their dung piles

This fossil is also the first evidence of communal latrines in backboned animals that aren't mammals, says Fiorelli. So while shared toilets are often thought of as a mammalian behaviour, other animals use them too.

The fossilized plants contained within the poop might also shed light on the plants these huge animals fed on, says Fiorelli. This is because when herbivores defecate, their poop often contains seeds from the plants they ate.

Even today, massive herbivores like elephants shape plant communities by dispersing seeds in their dung piles.  When they eat fruit, they serve up a cocktail of seeds with their dung. Some African elephants can disperse over 2000 seeds of diverse plants per square kilometre, every day.

Animal communal latrines seem to have a number of functions – from a way to communicate with each other, to defending territories and resources.

In contrast, human public toilets are officially all about sanitation. But that hasn't stopped people from co-opting them for other purposes, such as leaving graffiti, and we don't know what purposes the earliest humans had when they constructed their latrines.

"It's interesting to wonder if the deeper origins of toilet behaviour in humans might have been at least partially motivated by some of the same motivations experienced by non-human primates today," says Irwin.