One of the stranger aspects of Africa's rapid urbanization is the influx of livestock in new, unplanned towns -- and the diseases they bring with them.

Dagoretti, a district of Nairobi, is a maze of tin huts and wood shacks. Since the 1970s, it's grown from about 40,000 residents to roughly 240,000, springing up haphazardly as Nairobi spilled over into the surrounding land. There aren't clearly delineated plots so much as a mass of semiformal homes belonging to former country folk who've arrived in search of economic opportunity.

Today, about 40 percent of the African population lives in urban areas, a rapid migration that's expected to triple in size over the next four decades.

But the people who are moving to cities aren't entirely leaving their rural lives behind. Instead, they are bringing their livestock with them, often keeping them right in their backyards, even in densely populated areas.

As a result, low-income countries have started to see a dramatic spike in a class of disease known as zoonoses, which pass from animals to humans. These can cause everything from tapeworms to fatal diarrhea, and they're concentrated near major cities in Africa and India.

A recent study by the International Livestock Research Institute found that zoonoses make up 26 percent of the infectious disease burden in low-income countries, but just 0.7 percent in high-income countries.

Now, researchers are beginning to trace these ailments to the livestock that sleep just over the windowsill from the residents of the developing world's newest cities.

In Dagoretti, one in 80 people keep cattle, and 60 percent of households have poultry. A typical house there might have a shed full of rabbits or chickens under the bed. A cow kept in the yard may graze by the roadside or munch potato peels from a local eatery.

But animals and cities don't always mix well. Throughout history, as cities modernized and developed, any lingering livestock were soon banished to the countryside.

That's not an option for people in places like Dagoretti, where there are still very few grocery stores, and low incomes mean many residents rely on raising and selling their own food. For the town's infants and children, the nutritional benefits of ready access to milk outweighs some of the cow-related drawbacks.

(International Livestock Research Institute)

"In cultures where you don't do fridges or freezers, there's a huge demand for milk and meat and it needs to be close to where it's eaten," says Delia Grace, a Nairobi-based researcher for the International Livestock Research Institute.

A cow can also be used as collateral for those lacking the money to get bank loans.

"You can use the cow as surety. With a cow, you can leverage funds, you can get a loan," Grace says.

But animals and cities don't always mix well.

For these and other reasons, Dagorettians won't -- and probably shouldn't -- get rid of their cows and other animals.

("Our final conclusion was 'keep on keeping your cows,'" Grace says of her research in the area.)

But as person and cow live side by side, the result has been a fascinating example of what happens when old traditions collide with new urban practices within Africa's cramped and unplanned cities.

Cities are changing fast. Keep up with the CityLab Daily newsletter.

The best way to follow issues you care about.

A disease called Cryptosporidiosis, which causes gastrointestinal distress and diarrhea, was just one of the diseases Grace and her colleagues uncovered in Dagoretti and other regional hot spots. The culprit? Salad.

Cows produce nearly 44 pounds of waste per day, and many residents spread the unprocessed manure on their small backyard gardens as a type of fertilizer. These vegetables were later used to make a popular, uncooked relish called kachumbari.

This unconventional lifestyle called for a similarly unorthodox approach to preaching food safety. Grace and her colleagues determined that the best way to stop the spread of crypto was not to discourage the keeping of animals, but to get residents to do it more carefully. And the best way to accomplish that, they found, was peer pressure.

"Much of the conventional communication - 'don't do this, it'll make you sick' -- we know that's not very effective. There's a new approach that's trying to change peoples' behavior based on social norms," Grace explained. "People are more concerned with how they appear in the community than following health codes."

Over the course of several months, the researchers crafted cartoons and brochures filled with messages that "a good neighbor" or "a clean person" composts their manure, say, or uses gloves when cleaning up animal waste.

At one point, they even sponsored an episode for a local soap opera, "Makutano Junction," in which a character contracts crypto after drinking some unboiled milk.

"Living next to animals means she has to keep proper and good hygenic standards," says one character, Maspeedy, to a woman whose mother is feeling sick. "I've seen her milking her cow in her slippers, without proper garments on!"

It's not exactly Emmy-winning dialogue, but as Dagoretti and other African insta-cities try to figure out urban life, it could be a useful tip nonetheless.