Many Americans consider San Francisco and Berkeley two peas in a very liberal pod — both of them far-left, wacky cities filled with pot-smoking, quinoa-eating eccentrics whose mayoral candidates go by names like Chicken John (San Francisco, 2007) and Running Wolf (Berkeley, 2012).

But there are plenty of differences between the two bluest of blue Bay Area cities. Take a look at Tuesday’s election and the very different outcomes for both cities’ attempts to pass a tax on sodas.

Berkeley became the first city in the nation to adopt a soda tax after 30 other cities and states around the country failed. Its Measure D levied a penny-per-ounce tax on sugar-sweetened drinks. Its revenues weren’t pegged for any particular purpose so it needed just a simple majority, but it won the support of a whopping 75 percent of voters.

San Francisco, always a city that loves being first, instead became the 31st municipality to opt not to adopt a soda tax. Its Proposition E would have levied a 2-cents-per-ounce tax, and it needed two-thirds of voters to support it because it would have directed revenue to physical education and nutrition programs for children. A majority of San Francisco voters, 55 percent, supported Prop. E — but that wasn’t enough for it to win.

There was, of course, a lot of Wednesday morning quarterbacking after the election — and a lot of thoughts as to why two such similar cities had two such different outcomes.

One is simple demographics. Berkeley is smaller, whiter and a bit wealthier than San Francisco. A number of political observers likened Berkeley to one big Noe Valley. And it’s those Noe Valley types who were most likely to vote for a soda tax.

Corey Cook, a political science professor at the University of San Francisco, used preliminary election results to create precinct-level maps showing how residents voted on the city’s various propositions.

If all of San Francisco voted along the lines of the Castro, Haight, Potrero Hill and, yes, Noe Valley, the soda tax would have won. But neighborhoods with more low-income and minority voters, including Chinatown, Bayview-Hunters Point and Visitacion Valley, voted against the tax.

That has been the case in just about every city that has tried to pass a soda tax. The American Beverage Association, which funneled $9.1 million into defeating Prop. E, often concentrates its campaign spending in low-income, minority neighborhoods — and wins.

Georgetown University Professor Lawrence Gostin, who specializes in public health law and supports soda taxes, said the strategy is common because low-income people drink more soda and cannot easily afford the extra taxes. To win them over, soda tax proponents must work closely with churches, health advocates and community leaders in those neighborhoods.

“We need to consult them, engage them and have the voice come from them,” he said. “They need to say, 'We won’t stand for this for our children.’”

Supervisor Eric Mar, an author of Prop. E., said the campaign to pass the soda tax didn’t do enough outreach in Chinese, black and immigrant neighborhoods.

“Our grassroots campaign needed to start earlier in the low-income communities,” he said. “That was one of the weaknesses.”

Mar said another problem with San Francisco’s measure was the way it got started. He spearheaded the oft-mocked, yet ultimately successful ban on free toys in Happy Meals in 2010 and used the excitement among health advocates on that measure to fuel talk of a soda tax.

Mar and his progressive colleague, Supervisor John Avalos, said they’d been working closely with UCSF researchers and others to craft the soda tax, but that Supervisor Scott Wiener then came in and took over.

“We were surprised when he jumped out with his soda tax proposal,” Mar said. “We need more discipline among the elected officials in how to support the coalition and not move forward prematurely as individual supervisors.”

Mar said he had wanted to wait until the November 2015 ballot at the urging of Mayor Ed Lee, who didn’t want the soda tax to distract from other measures on Tuesday’s ballot, but that Wiener rushed the issue.

“I think if we had done what the mayor’s office wanted, there would have been strong support in 2015,” Mar said.

Wiener scoffed at that notion. “There wouldn’t have been any difference between this year and next year in terms of support,” he said. “Sometimes you have to pull the trigger and move forward. Sometimes when you’re working on a policy issue that’s hard or there’s going to be opposition, you can get stuck and there can be some inertia.”

At the July Board of Supervisors meeting to place the measure on the ballot, four supervisors surprised their colleagues by speaking out vehemently against the tax. Lee refused to take a stand.

Berkeley, however, had a strong, citywide coalition that had been building for years and had early buy-in from a host of minority community groups.

Polling in Berkeley consistently showed about 60 percent of voters backing the tax, even if the revenue wasn’t pegged for any particular purpose. Polling in San Francisco showed that voters were much more likely to back the soda tax if they knew revenue would be spent on kids’ programs and not just funneled into the city’s general spending account. Supporters still think they were right to go for the measure requiring two-thirds support, but it cost them a lot of money.

That’s because former New York Mayor Michael Bloomberg — he of the ill-fated attempt to ban the Big Gulp — in mid-October gave $85,000 to the campaign to pass Measure D in Berkeley, which paid for cable TV ads during the World Series and is credited in part with pushing the level of support so high.

Bloomberg never gave any money to the San Francisco campaign, though supporters of that soda tax effort were expecting it. Howard Wolfson, senior adviser to Bloomberg, said the two-thirds requirement made the measure not viable.

“I hope that the folks there who were very passionately committed to this issue decide to look at it again and think about putting it on the ballot in a different year and a different form,” Wolfson said.

Money, or lack thereof, was the hardest part of the campaign, said campaign manager Maureen Erwin. Despite a lengthy and impressive list of endorsements, donations just didn’t come through. The campaign raised a total of just $255,000.

“We had no funding to execute any communication strategy,” she said, saying there are a lot of foundations funding health research and education, but not political change. “They’re going to have to get political. Type 2 diabetes is political, I’m sorry.”

The San Francisco soda tax supporters say they’ll try again. They plan to meet in the next few weeks to decide their game plan, and Mar said it could reappear on the ballot as soon as next November.

Their first effort may have gone flat like a can of Coke left unopened too long. But they now know it can work — across the bay anyway.

Heather Knight is a San Francisco Chronicle staff writer. E-mail: hknight@sfchronicle.com Twitter: @hknightsf