Engineers and developers work at President Obama's campaign headquarters in Chicago in December 2011. (Joel Kowsky/BLOOMBERG)

From the moment Barack Obama took the oath of office on Jan. 20, 2009, and every day thereafter, his team was always preparing for the 2012 campaign. Everyone said Obama’s 2008 operation had rewritten the book on organizing. But that was just a beginning, a small first step toward what the team envisioned when it began planning the reelection campaign.

In one of their first conversations about 2012, campaign manager Jim Messina said he told the president that they could not rerun 2008. Obama seemed puzzled. “You know we won that one,” Obama said. Messina said too much had changed. For one thing, Obama was now an incumbent with a record. But technology had also leapfrogged forward, with new devices, new platforms and vastly more opportunities to exploit social media. The whole campaign would have to be different.

The president sent the team off to Chicago, far away from the hothouse of Washington and Beltway chatter, to use 2011 to build the foundation and reassemble the army from 2008. As the Republican candidates were gearing up and then battling one another through the summer and fall of 2011, the Obama team was investing enormous amounts of time, money and creative energy in what resembled a high-tech political start-up whose main purpose was to put more people on the streets, armed with more information about the voters they were contacting, than any campaign had ever attempted.

The Obama team had to be better in 2012. The weak economy made the president vulnerable to defeat. His political advisers knew well that turning out the vote would be far more challenging in the reelection effort than it had been in 2008. Many of his early supporters were disappointed and some were outright frustrated with Obama’s performance in office. The advisers recognized that Republicans were trying to block his agenda by questioning whether he had the leadership skills or the tenacity to get done what his first campaign had promised. Obama advisers also knew this campaign would have to be far more negative than the first — with few of the aspirational themes of 2008 — and they began preparing to attack Mitt Romney, the presumed challenger, long before the Republican primaries and caucuses began.

One of the hallmarks of Obama’s 2012 campaign was its prodigious appetite for research. The trio at the top — Messina, senior strategist David Axelrod and White House senior adviser David Plouffe — were enthusiastic consumers of research. Though different in their approaches to politics — Axelrod operated intuitively, Plouffe’s watchwords were “Prove it” and Messina wanted to be able to measure everything — they all pushed the campaign for more research, testing, analysis and innovation.

Message and media operated on one track. The other track focused on identifying, registering, mobilizing and ultimately turning out Obama voters. At the Chicago headquarters, these efforts were guided by Messina and Jen O’Malley Dillon, the deputy campaign manager, along with a sizable team of political organizers and tech-savvy newcomers.

“There’s always been two campaigns since the Internet was invented, the campaign online and the campaign on the doors. What I wanted was, I didn’t care where you organized, what time you organized, how you organized, as long as I could track it, I can measure it, and I can encourage you to do more of it.”

Jim Messina, President Obama’s 2012 campaign manager

The first steps toward building the reelection operation around a single target — maximizing turnout to reach 270 electoral votes — were taken in the months after Obama’s 2008 victory. Campaign staffers compiled a series of after-action reports. “We did a very detailed postmortem where we looked at all kinds of numbers, looking at the general stuff like the number of door knocks we made, phone calls we made, number of voters that we registered,” said Mitch Stewart, who would direct the campaign’s 2012 effort in battleground states. “But then we broke it down by field organizer, we broke it down then by volunteer. We looked at the best way or the best examples in states of what their volunteer organization looked like.”

The project produced a three-ring binder that contained nearly 500 pages and was filled with recommendations on how to strengthen what was already considered a state-of-the-art field operation. Another early step was the decision to massively expand the investment in technology, digital, cable, new media and particularly analytics.

The Obama campaign had the usual contingent of pollsters and ad makers and opposition researchers and, like all campaigns today, a digital director. But it also had a chief technology officer (who had never done politics before), a chief innovation officer and a director of analytics, which would become one of the most important additions and a likely fixture in campaigns of the future. The team hired software engineers and data experts and number-crunchers and digital designers and video producers by the score. They filled the back of a vast room resembling a brokerage house trading floor or tech start-up that occupied the sixth floor of One Prudential Plaza overlooking Millennium Park in Chicago.

No campaign had ever invested so heavily in technology and analytics, and no campaign had ever had such stated ambitions. “Technology was another big lesson learned from 2008, leap of faith and labor of love and angst-ridden entity and all the other things that you can imagine, because we were building things in-house mostly with people that had not done campaign work before,” Dillon later told me. “The deadlines and breaking and testing — is it going to work, what do we do? . . . At the end of the day, it was certainly worth it, because you can’t customize our stuff, and so we just couldn’t buy off the shelf for anything and you know that, and fortunately we had enough time to kind of build the stuff. I don’t know who else will ever have the luxury of doing that again.”

Messina was as data driven as any presidential campaign manager in modern times, and Dillon had concentrated her efforts while at the Democratic National Committee in 2009 and 2010 on the programs that would make Obama’s groundbreaking 2008 campaign look old-fashioned in comparison. They wanted all the data the campaign accumulated about voters to be integrated. The campaign had a voter list and a donor list and volunteer lists and other lists, but what it wanted was the ability to link all the contacts each person had with the operation into one database.

“There’s always been two campaigns since the Internet was invented, the campaign online and the campaign on the doors,” Messina told me. “What I wanted was, I didn’t care where you organized, what time you organized, how you organized, as long as I could track it, I can measure it, and I can encourage you to do more of it.” It took the technology team nearly a year, but it produced software that allowed all of the campaign’s lists to talk to one another. The team named it Narwhal, after a whale of amazing strength that lives in the Arctic but is rarely seen. Harper Reed, the chief technology officer, described it as the software platform for everything else the campaign wanted to do and build.

Obama speaks at a campaign event at Colorado State University in Fort Collins, Colo., on Aug. 28, 2012. (Nikki Kahn/THE WASHINGTON POST)

Supporters chant "four more years" during Obama's speech in Kissimmee, Fla., on Sept. 8, 2012. (Nikki Kahn/THE WASHINGTON POST)

The next goal was to create a program that would allow everyone — campaign staffers in Chicago, state directors and their staff in the battlegrounds, field organizers, volunteers going door to door and volunteers at home — to communicate simply and seamlessly. The Obama team wanted something that allowed the field organizers in the Des Moines or Columbus or Fairfax offices to have access to all the campaign’s information about the voters for whom they were responsible. They wanted volunteer leaders to have online access as well. That brought about the creation of Dashboard, which Messina later said was the hardest thing the campaign did but which became the central online organizing vehicle. It was enormously complicated to develop, made all the more difficult because the engineers who were building it had never worked on a campaign and did not instinctively understand the work of field organizers. Some of them were sent out to the states briefly as organizers to better understand the needs of those on the front lines.

“Dashboard is what we needed to communicate,” Dillon said. “It was all about the users, so if the users didn’t have a good experience, there was no point in it. . . . That’s why it was the Holy Grail.”

Reed described it as a way to bring the field office to the Internet. “When you walk into a field office, you have many opportunities,” he said. “We’ll hand you a call sheet. You can make calls. You can knock on doors, and they’ll have these stacks there for you. They’ll say: ‘Harper, you’ve knocked on 50 doors. That’s great. Here’s how you compare to the rest of them.’ But it’s all very offline. It’s all very ad hoc, and it’s not very modern. And so what we set out to do was create that offline field experience online.”

Jim Messina, Obama’s campaign manager, talks with reporters during a tour of the re-election headquarters in Chicago. (Frank Polich/GETTY IMAGES)

Reed said that near the end of the campaign they received an e-mail from a wounded Afghanistan war veteran who was in a hospital. He was logging into Dashboard and participating in the organizing effort the way any other volunteer walking precincts was doing. Reed was astonished by the message. He said, “I could have quit that day, and I would have been satisfied with my role.”

The Obama leaders not only wanted all the lists to be able to talk to one another, they also wanted people to be able to organize their friends and family members. This was taking a concept introduced in 2004 by George W. Bush’s reelection team — the notion that voters are more likely to listen to people they know than to paid callers or strangers knocking on their door — and updating it to take advantage of new technology, namely the explosion of social media.

Early in 2011, some Obama operatives visited Facebook, where executives were encouraging them to spend some of the campaign’s advertising money with the company. “We started saying, ‘Okay, that’s nice if we just advertise,’ ” Messina said. “But what if we could build a piece of software that tracked all this and allowed you to match your friends on Facebook with our lists, and we said to you, ‘Okay, so-and-so is a friend of yours, we think he’s unregistered, why don’t you go get him to register?’ Or ‘So-and-so is a friend of yours, we think he’s undecided. Why don’t you get him to be decided?’ And we only gave you a discrete number of friends. That turned out to be millions of dollars and a year of our lives. It was incredibly complex to do.”

But this third piece of the puzzle provided the campaign with another treasure trove of information and an organizing tool unlike anything available in the past. It took months and months to solve, but it was a huge breakthrough. If a person signed on to Dashboard through his or her Facebook account, the campaign could, with permission, gain access to that person’s Facebook friends. The Obama team called this “targeted sharing.” It knew from other research that people who pay less attention to politics are more likely to listen to a message from a friend than from someone in the campaign. The team could supply people with information about their friends based on data it had independently gathered. The campaign knew who was and who wasn’t registered to vote. It knew who had a low propensity to vote. It knew who was solid for Obama and who needed more persuasion — and a gentle or not-so-gentle nudge to vote. Instead of asking someone to send a message to all of his or her Facebook friends, the campaign could present a handpicked list of the three or four or five people it believed would most benefit from personal encouragement.

Harper Reed, chief technology officer for U.S. President Barack Obama's re-election campaign, speaks to engineers at campaign headquarters in Chicago on Dec. 13, 2011. (Joel Kowsky/BLOOMBERG)

Digital director Teddy Goff told my colleague Aaron Blake, “For people who allowed us, we were able to say to them: ‘All right, you just watched a video about registering to vote. Don’t just share it with all your friends on Facebook. We’ve run a match, and here are your 10 friends on Facebook who we think may not be registered to vote and live in Ohio, Colorado, Virginia, Florida.’ ” This was especially helpful in trying to reach voters under age 30. On Obama’s target lists, the voter file contained no good contact information for half of those young voters — they didn’t have land lines, and no other information was available. But Goff said 85 percent of that group were on Facebook and could be reached by a friend of a friend. Reed described another example. Someone interested in health care might click on an ad on Facebook, and up would pop an infographic about health care. At the end of it would be a “share” button, and if the person clicked on it, names of friends the person could share the information with would appear. The campaign knew from its own database which of those friends were most likely to respond to information about health care. “We went through and we looked at all those friends and found the ones that were the best matches for that specific piece of content,” Reed said.

Google’s Eric Schmidt, who offered advice to the campaign, said: “If you don’t know anything about campaigns you would assume it’s national, but a successful campaign is highly, highly local, down to the Zip code. The revolution in technology is to understand where the undecideds are in this district and how you reach them.” That was what the integration of technology and old-fashioned organizing was designed to do for Obama in 2012.

An iPhone displaying an Obama 2012 election campaign application sits at Obama's campaign headquarters in Chicago on Dec. 13, 2011. (Joel Kowsky/BLOOMBERG)

Dan Wagner had come to the DNC after the 2008 election to expand what was initially a tiny analytics operation. In early 2010, others on the Obama team had an epiphany about the value of analytics. It came just before the special election to fill the Senate seat of the late Edward M. Kennedy in Massachusetts. Many Democrats were still in denial about the direction of the race, incredulous that a little-known Republican state senator named Scott Brown could have enough momentum to defeat Democratic state Attorney General Martha Coakley. Wagner, who was operating with the analytics team out of the DNC, analyzed the numbers and surmised that Brown would win. He delivered his conclusions and the data to Messina. “He said, ‘We’re going to lose, and here’s why we’re going to lose,’ and it happened almost exactly like that,” Messina said. “That’s when we first started saying this modeling can really be something.”

Dillon and national field director Jeremy Bird brought Wagner to the re­election campaign. Eventually the team modeled practically everything — voters, states, volunteers, donors, anything it could think of to improve efficiency — to give it greater confidence in its decision making. It wanted to know who was most likely to serve as a volunteer, and it created a model to find out. The campaign established record numbers of offices in the states, and record numbers of staging areas for volunteers, based in part on analysis of how much more likely people were to volunteer if they were close to an office. “We built a model on volunteer likelihood,” Stewart said. “We built a model on turnout, we built a model on support, we built a model on persuasion — who’s most persuadable.”

From modeling and testing, the campaign refined voter outreach. Virtually every e-mail it sent included a test of some sort — the subject line, the appeal, the message — designed to maximize contributions, volunteer hours and eventually turnout on Election Day. The campaign would break out 18 smaller groups from e-mail lists, create 18 versions of an e-mail, and then watch the response rate for an hour and go with the winner — or take a combination of subject line and message from different e-mails and turn them into the finished product. Big corporations had used such testing for years, but political campaigns had not.

The team’s attention to detail rivaled that of the most successful corporations. One innovation was the recruitment of corporate trainers or coaches, who volunteered to help teach everyone how to manage. “We recruited a whole group of pro bono executive coaches,” Bird said. “These are people that coach Fortune 100 companies.” Obama’s team recruited them as volunteers, but instead of having them knock on doors, they were asked to provide management training. “We had them partner up with our state leadership,” Bird said. “They didn’t need to know anything about campaigns, because we didn’t want their advice on how to run a campaign. We wanted their advice on how to be a manager.”

The campaign also sought advice from what the New York Times later called a “dream team” of academics who described themselves as a “consortium of behavioral scientists.” The group included political scientists, psychologists and behavioral economists. The campaign was operating well outside the traditional network of political consultants.

Throughout 2011, Obama advisers were baffled by the slow start to the Republican presidential race. They knew from their experience in 2008 how long it took to build a field operation capable of winning a campaign. They were even more keenly aware of the lead times and money required to assemble the technological infrastructure to support a sophisticated get-out-the-vote operation for 2012. Republicans could see that the Obama campaign was spending tens of millions of dollars in 2011. They just weren’t sure on what.

Approximately 9,000 people gathered in the rain for rally with President Barack Obama at Cleveland State University in Cleveland, Ohio, on October 5, 2012. (Nikki Kahn/THE WASHINGTON POST)

The gap between the Obama and Romney operations crystallized in the key battleground state of Ohio in the closing weeks of the general-election campaign. Members of Obama’s team had been on the ground in Ohio for years. They knew the state intimately. Obama had at least 130 offices there, plus 500 or so staging areas for volunteers. He had almost 700 staffers on the Ohio payroll alone. Thousands of volunteers contacted voters.

Romney had to put together an organization in a matter of months. He had about 40 offices and 157 paid staff members, although most of them were on the Republican National Committee’s payroll. Scott Jennings, Romney’s Ohio state director, said after the election that there was no way the Republicans could conquer Obama’s head start. “Our ground game was as good as it could have possibly been, given the time and resources we had to work with,” he said. “There’s just no substitute for time. Six months . . . wasn’t enough to overcome six years of a constant campaign run by the other side. Truly it is remarkable to see what they did, in the rearview mirror.”

Aaron Pickrell, Obama’s chief Ohio strategist, told a story about himself that illustrated the disparity between the two campaigns’ ground operations. An Obama volunteer knocked on his door during the summer, just to check in and see if he had any questions. The volunteer did not know who Pickrell was. He knew, based on campaign data, only that Pickrell should be a solid Obama voter, someone who needed to be contacted once at most.

Pickrell and his wife later ordered absentee ballots. When the ballots arrived, they set them aside on the kitchen table, where they sat for two weeks. “I got thrown back into the database of people who needed to be contacted,” he said. Soon an Obama volunteer knocked on their door to remind them to turn in the ballots. Once they did, there was no more contact. That was the level of the campaign’s efficiency. Meanwhile, Pickrell said he received a dozen direct-mail pieces from the Romney campaign, a waste of money and effort on the Republicans’ part. He got no direct mail from the Obama campaign because the database said he didn’t need persuading. Rich Beeson, Romney’s political director, eventually learned the scope and sophistication of the Obama operation. “They took that to another level,” he said.

Through modeling, voters were rated on a scale of 1 to 100 on their likelihood to support Obama. A similar scale was used to predict the likelihood that people would turn out. So if someone had a high support score and a low turnout score, meaning that person was very likely to support Obama but not so likely to vote, the campaign tried to make sure that person got registered and then cast a ballot, preferably during the period of early voting. Banking those sporadic voters became a top priority.

The Obama team had done support and turnout estimations in 2008 but more experimentally. This time, the campaign added a third measure, a persuasion score. This helped weed out people who said they were independent but really were not. In the final weeks of the campaign, the team focused on voters with persuasion scores of 40 to 60. Those with higher scores were likely to vote for Obama without much persuasion. The others probably weren’t going to back the president no matter how open they said they were.

“In the old days you would say, ‘Here’s a list of people we think are independents, go to those houses,’ ” Messina said. “But you waste your volunteers’ time all over the place because despite what someone says, there are a very small amount of undecided voters.” By knowing the voters and modeling the electorate, the campaign wasted less time pounding the pavement.

No get-out-the-vote operation works precisely as planned — or as characterized in after-action reports by the winning campaign. It always sounds better than it is. On the streets, it never looks as smooth as described at headquarters. But the payoffs for Obama were real on Election Day.