The 12 Democrats who qualified for Tuesday’s debate are trying to reach specific voters with Facebook ads.

Note: Facebook ad spending data from March 24 to Oct. 5. | Sources: Bully Pulpit Interactive; Facebook

When it comes to former Vice President Joseph R. Biden Jr.’s Facebook ads, the odds are overwhelming that people seeing them were born before 1975. For Senator Bernie Sanders of Vermont, the opposite is true: People born in 1975 or after are more than twice as likely to see his Facebook ads than those born earlier. A gender split is clear, too: About half of Mr. Sanders’s audience are men, while about two-thirds of Mr. Biden’s are women.

Senator Elizabeth Warren of Massachusetts, more or less, splits the difference between them. She has targeted a Facebook audience that more closely mirrors the projected universe of likely Democratic primary voters in 2020: more women than men (though not by as much as Mr. Biden), leaning older more than younger (but again, not by as much as Mr. Biden).

Collectively, the 19 current Democratic candidates for president have poured nearly $32 million into Facebook ads this year — more money than they have spent so far on television ads, a striking measure of the social network's ever-rising influence in politics. The heavy spending on Facebook comes even as leading party officials have raised alarms about the site’s role in American democracy.

Ms. Warren sparred with Facebook in recent days over the company’s willingness to run false ads. She has been a heavy spender nonetheless, pouring $172,000 into the site over the seven most recent days records are available.

The advertising decisions that each campaign makes on one of the Internet’s biggest platforms offer an almost unparalleled window into their political priorities and strategies, illuminating their core supporters and providing a glimpse into their potential coalitions. The spending patterns reveal not just who the campaigns are targeting but where.

The 2020 race marks the first presidential campaign where Facebook is publicly publishing who is buying ads — and whom they are targeting. This story is based on Facebook data compiled and analyzed by Bully Pulpit Interactive, a Democratic consultancy. Its database includes estimates of which gender and age group every candidate has targeted since March but not does not include race or ethnicity, which Facebook does not explicitly allow campaigns to use for targeted ads.

Because campaigns receive so much real-time feedback from Facebook, they are able to precisely hone their audiences.

“You can prioritize toward people taking the action you want them to take,” said Alex Kellner, a Democratic strategist at Bully Pulpit. “Facebook helps you optimize toward the outcome you want.”

Aside from Mr. Sanders and Mr. Yang, candidates are mostly reaching out to older voters.

Note: Includes only spending where gender is identified.

Among the leading candidates, Mr. Sanders targets a younger and more male audience on Facebook. That mirrors his support in polls, which regularly show him strongest among young voters, and performing better among men than women.

“There’s a reason why they’re called ‘Bernie Bros,’” said Jefrey Pollock, a Democratic pollster who formerly advised Senator Kirsten Gillibrand’s campaign. “Nothing about him targeting younger men is surprising to me.”

One of the most striking findings of the Facebook advertising data is just how little Mr. Biden is spending to reach the youngest generation of voters. Less than one half of 1 percent of Mr. Biden’s Facebook ad buys have targeted users born in 1995 or later. That was the smallest share — and smallest dollar amount — that any of the 11 other candidates who will be on the debate stage Tuesday spent for any age segment.

Mr. Biden spent less than $12,000 targeting voters younger than 25 through the beginning of October. Mr. Sanders spent nearly half a million dollars targeting the same age group, according to Bully Pulpit.

Emily Williams, a Democratic digital strategist who worked on Barack Obama’s first presidential campaign, said Mr. Biden’s lack of spending on young voters was a cause for concern. “It says to me that they’re struggling to break through with younger voters,” she said, “and I hope it doesn’t mean they’ve given up on younger voters.”

Mr. Biden’s bread and butter was older women: Fifty-five percent of his entire Facebook ad budget was devoted to women 45 or older, including some ads last month about Medicare.

The targeted audience for this Biden ad on Medicare was overwhelmingly women 65 or older. Source: Facebook

It makes sense that the demographic groups targeted by the leading candidates look a lot like their existing supporters, digital strategists said, because much of the advertising so far has been seeking out new donors. A campaign’s best bet is serving ads to its base.

Still, the degree to which Facebook advertising aligns with polling can be almost eerie.

In a Quinnipiac poll last week, Mr. Biden led the field by a wide margin among voters who were at least 65 years old — the same segment he tops in Facebook ad spending. In the same survey, Mr. Sanders dominated among those 18 to 34 years old — where Mr. Sanders dominates in spending. Ms. Warren came in second in the poll among both extreme ends of the age spectrum, while she led among voters 35 to 65 years old.

On Facebook, Ms. Warren’s share of spending fell in between Mr. Sanders’s and Mr. Biden’s for every age segment.

Her spending splits were closely aligned with those of Mayor Pete Buttigieg of South Bend, Ind., whose spending skewed slightly younger and more male. The age and gender groups targeted by the billionaire Tom Steyer, who entered the race in July and has quickly outspent all his rivals, was similar to Mr. Buttigieg and Ms. Warren.

“A new generation of leadership” ad from Mr. Buttigieg’s campaign targets older women. Source: Facebook

A majority of Mr. Buttigieg’s Facebook spending has gone to those aged 45 years and above, despite running as a candidate for a “new generation,” a phrase featured in some of his ads. (Mr. Buttigieg wrote in his autobiography that back in his first run for mayor as a 29-year-old, older voters were more likely to see his youth as a positive.)

Candidates’ ad spending largely skews female.

Almost all of the candidates in the debate on Tuesday are advertising to a majority-female audience on Facebook. But the campaign most lopsidedly targeting women on Facebook is not one of the four female candidates at the debate, but Julián Castro, the former federal housing secretary. Jennifer Fiore, a senior adviser to Mr. Castro, was not surprised by that fact.

She noted that Mr. Castro’s campaign manager and other top strategists are women and that Mr. Castro has made his mother a big part of his pitch, featuring her in video ads on Facebook earlier this year. (Of late, the campaign has also run Facebook ads with pictures of puppies, touting that Mr. Castro would “make animal abuse a federal crime.”)

An ad about Julian Castro’s pet euthanasia policy was shown mostly to women. Source: Facebook

“We’re targeting women because women are responding,” Ms. Fiore said.

That self-reinforcing truism is a feature across the platform: Operatives said that Facebook’s formulas encourage advertisers to double-down on whatever demographic groups are already clicking, driving those candidates with older bases to target ever older audiences, and vice versa.

That, for instance, is how Andrew Yang, the former tech executive, is targeting an overwhelmingly male and young audience. (Representative Tulsi Gabbard of Hawaii skews slightly more male but she is spending a fraction of what Mr. Yang is.)

A cartoon of Andrew Yang performing the Floss , a dance move popular in the video game Fortnite. The ad skews to a younger male audience. Source: Facebook

An ad with Ms. Gabbard describing her foreign policy while standing in front of an American flag was disproportionately shown to men. Source: Facebook

“The Facebook algorithm optimizes for people who are taking action,” said Eric Ming, the director of paid media for the Yang campaign, explaining that Mr. Yang’s demographics are younger and more male because that is where his message is resonating. The ads also often feature cartoon character versions of the candidate.

Digital strategists describe three phases to online advertising in campaigns. The first is acquiring new donors and supporters. The second is persuading undecided voters. The third is getting people out to vote.

For the most part, campaigns have been focused on the first phase. But some have begun to invest in persuasion — and it’s visible in their geographic splits.

Mr. Buttigieg and Mr. Steyer are dominant in the first four voting states.

Note: Data from Sept. 1 to Oct. 5. | Source: Bully Pulpit Interactive

For Senator Kamala Harris of California, her biggest states for advertising in the spring were those with the biggest populations: California, New York, Texas and Florida. But in July, she shifted. Her biggest state for Facebook advertising in each of the last three months has been Iowa, a shift made in spending priorities long before she publicly announced her “pivot” to focus on that state’s leadoff caucuses.

In September, for the first time, South Carolina jumped up to one of her biggest spending states. That month, she spent $52,000 there on Facebook, second to Mr. Steyer.

Mr. Buttigieg has been the biggest spender on Facebook nationally, besides Mr. Steyer and his virtually unlimited budget. Mr. Buttigieg’s dominance is particularly apparent in the opening states of Iowa and New Hampshire. In September, Mr. Buttigieg was the top spender in both states by a wide margin. In fact, he spent more than all his rivals, other than Mr. Steyer, combined.

As the Democrats have focused on the critical primary contests, President Trump has flooded Facebook with messaging aimed at the general election. In the last month, he spent more than $700,000 on Facebook ads just in Michigan, Pennsylvania, Wisconsin and Florida — four swing states he narrowly carried in 2016.

“Danger, danger, danger!” said Betsy Hoover, who was the director of digital organizing for Mr. Obama’s re-election campaign and is unaligned in the 2020 primary.

Ms. Hoover said she worries that Democrats are “focusing on the coasts or early states — none of which matter in the general,” while Mr. Trump is delivering his message to key voters.

“We are running a primary strategy and Trump is running a general election strategy,” she said, “And that’s terrifying.”