For all the parties and players grabbing credit the morning after Terry McAuliffe’s victory in the Virginia governor’s race, it turns out the Democrat’s win may well have come down to three elements: A massive data file, a very sharp model of the electorate, and Judge Judy.

Not necessarily in that order.

McAuliffe’s victory can be measured in simple numbers: He got 1.06 million votes, roughly 50,000 more than Attorney General Ken Cuccinelli II (R) did. His workers and volunteers knocked on more than 2 million doors. He raised more than $35 million — nearly double what Cuccinelli did.

But McAuliffe also deployed numbers in far more sophisticated fashion, and he did it with the help of many of the same wonks who powered President Obama to victory in 2008 and 2012. Like Obama, McAuliffe leaned heavily on data, compiling reams of information on voters across the commonwealth. And that hefty bank account gave him the resources to put it to good use.

The bulk of McAuliffe’s data work was done by BlueLabs, a firm launched earlier this year by veterans of the Obama analytics operation. The company has roughly 20 employees, and nearly all of them worked for the president’s campaign last year. They include Daniel Porter, who served as Obama’s director of statistical modeling, and Matthew Holleque, who was Obama’s deputy in the modeling department.

“The Obama campaign in 2008 and 2012 wanted to measure everything: What channels to advertise on, at what times? What doors to knock on?” said Kassia DeVorsey, a BlueLabs principal who served as a senior analyst for Obama. “We ended up doing a lot of that same work for McAuliffe in Virginia . . . the whole 9 yards.”

Although the final vote margin was closer than public polls suggested, the model BlueLabs built turned out to be accurate, according to the McAuliffe campaign.

“Our terrific Blue Labs analytics team, which conducted modeling calls on an ongoing basis, consistently modeled this as a two point race,” Geoff Garin, McAuliffe’s pollster, said Wednesday.

It started with the rankings.

Virginia Democrats have built up a file that includes data on every single voter in the commonwealth, combining basic demographic information with experience gleaned from multiple recent campaigns. If someone knocked on a voter’s door during a 2010 congressional race, that voter’s response was added to the file.

The party also has a vast trove of consumer data about voters’ shopping and media viewing habits. All of that information was merged together, and every Virginia voter was assigned a score from 1-100. If a person scored an 85, that meant there was an 85 percent chance they’d back McAuliffe.

Using those scores, Democrats ranked every voter in the state based on the likelihood they would back the party on Election Day.

Then the McAuliffe campaign tried to figure out where it needed each demographic — African Americans, unmarried women, college-educated suburban men, and so on — to be in order to eke out a victory.

“When you’re looking at an off-year election, you might assume the program would be overwhelmingly turnout-driven,” DeVorsey said.

But rather than just focusing on motivating existing supporters to turn out, she said. “we built this voter persuasion model . . . to identify the voters who are likely to be persuaded to vote for Terry McAuliffe once they hear his message.”

Delivering the message to those specific groups included old-fashion door-knocking and phone calls — supplemented by that big data file, telling field workers which doors to hit and which to skip — as well as social media and targeted advertising buys.

The McAuliffe team outspent Cuccinelli by millions on the airwaves, but the Democrat didn’t just advertise on the local news and the “Today” show. It also found particular success advertising on weekday episodes of “Judge Judy,” “Dr. Oz” and “The Wendy Williams Show” as well as late-night weekend repeats of “Private Practice” and “Castle.”

McAuliffe concentrated huge firepower on persuading women voters, mostly with ads about Cuccinelli’s record on issues like abortion, contraception and divorce laws.

“The most prominent messages you saw were exactly what was working,” said Elan Kriegel, a BlueLabs principal who was Obama’s battleground states analytics director.

In addition to advising McAuliffe from the outside, Blue Labs also had a staff member, Harrison Kreisberg, embedded with the McAuliffe campaign to weigh in during strategy sessions. The McAuliffe campaign and the Democratic Party of Virginia paid BlueLabs just over $200,000 combined for the firm’s services, according the Virginia Public Access Project.

The techniques BlueLabs and McAuliffe used aren’t so secret anymore. Obama’s operations have been much-studied, and Republicans now use some of the same techniques. But the Obama campaigns remain the gold standard.

“The big worry was that we wouldn’t be able to take what we did for the Obama campaign” and apply it to a state race,” Kriegel said. “We were able to find a way to boil it down.”

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.

To pause and restart automatic updates, click "Live" or "Paused". If paused, you'll be notified of the number of additional comments that have come in.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.