Coastal geography also plays a role. Cove-like stretches such as those at Cowell and La Jolla are at a disadvantage because pollutants are less readily washed out to sea.

And beaches near creeks, rivers or storm drains absorb the brunt of urban runoff.

Humboldt County’s Clam Beach, which is fed by two creeks, was named California’s most polluted beach by Heal the Bay.

The problem there has vexed local environmentalists who cite a panoply of possible causes: bird poop, campground toilets, old septic systems, livestock and more.

“There’s no shortage of theories,” said Jennifer Kalt, the director of Humboldt Baykeeper, an environmental group.

Better understood is that bacterial pollution rises sharply immediately after a rain, then typically goes right back to normal. That’s why health experts recommend beachgoers wait three days to enter the ocean after a storm.

(You can also check Heal the Bay’s online tool for the latest beach conditions).

“I think oftentimes people think kids just get diarrhea or stomach aches for other reasons,” Ms. Kalt said. “But studies have shown that it’s often correlated with rainfall. If it rains one day and then the next day it’s sunny, people don’t really give it much thought.”

Heal the Bay, based in Santa Monica, also noted some bright spots with an “honor roll” of beaches that maintained exceptional water quality year-round.