Understaffed, outspent, and running way behind in the polls, Donald Trump’s presidential campaign appeared to be floundering weeks before Election Day. But he got some help from a platoon of at least eight staffers from Facebook, Twitter, Google, and Microsoft that helped the Trump team hone its digital strategy.

While it’s not unusual for tech companies to provide de-facto consulting for big advertisers, the number and the extent to which employees from those companies acted as surrogate staff for political campaigns in 2016 was unprecedented in national politics, according to a study from that professors from the University of Utah and the University of North Carolina at Chapel Hill published in the journal Political Communications.

Those staffers, two each from Twitter and Facebook, and one from Google, and three from Microsoft, joined 12 more digital experts embedded in the campaign from Cambridge Analytica, the Boston-based data firm which is under investigation in both the U.S. and abroad, and is funded by Trump benefactor and billionaire Robert Mercer. The Facebook, Google, and Twitter employees worked on Trump’s digital ad strategy; Microsoft’s three staffers worked with the RNC on digital infrastructure and traveled occasionally to the Trump team’s digital headquarters in San Antonio.

Taken together, the Trump campaign had at least 20 outside staffers with extensive data analytics and digital marketing expertise to drive a strategy that propelled Trump to a big electoral margin on Election Day. Beginning on Tuesday, executives from Facebook, Google, and Twitter will face a series of hearings on Capitol Hill to answer questions about how Russian propaganda was spread so effectively across their networks.

The embeds from Silicon Valley traveled to campaign office several times a week to assist with digital ad buys, including who the campaign should be targeting and how much the Trump campaign needed to spend to reach his desired audiences, according to a RNC official.

Red state tech

Like a lot of political consultancies that specialize in servicing one side of the political aisle or the other, big tech firms have hired specialists in red and blue politics, making them particularly useful to Trump, which took full advantage.

“These firms have developed organizational structures and staffing patterns that accord with the partisan nature of American politics,” said UNC’s Daniel Kreiss and Utah’s Shannon McGregor, the authors of the new study. “Further, Facebook, Twitter, and Google go beyond promoting their services and facilitating digital advertising buys, actively shaping campaign communication through their close collaboration with political staffers.”

Similar offers of support was made to Hillary Clinton’s campaign, which turned it down in favor of using their own strategists and more fully built-out digital operation, a source familiar with the matter told VICE News. “Clinton viewed us as vendors rather than consultants,” one anonymous representative of a tech company told Kreiss and McGregor.

These Silicon Valley giants operated as de facto digital advertising sales consultants during last year’s election, on behalf of multiple Democratic and Republican campaigns both prior to and during the general election.

But these “consultants” and embeds were not provided freely as an act of political charity; these tech workers more easily facilitate the purchase of advertising and other technology services, which makes it easier for tech companies to make money from the election cycle.

In separate statements, Twitter, Google, and Facebook told VICE News basically the same thing: they provide these kinds of services to corporate customers as well as campaigns, and they offer them to campaigns regardless of their political affiliation. A Microsoft spokesperson said in a statement that it “did not embed staff at the Trump campaign offices.”

The Trump 2016 campaign digital chief Brad Parscale responded to a Politico report that first outlined the details of the study by disputing its characterization of embeds’ work as “free.”

A representative for the Clinton campaign did not respond to multiple requests for comment.

Silicon Valley in DC

Tech companies have offered these services to political campaigns for years; experts in the field point to Howard Dean’s digital mobilization during the 2004 cycle as the moment that politicos started taking notice. And in 2008, staffed with Dean alums, Barack Obama leaned heavily on Facebook to get the message out about his first presidential campaign.

All major tech platforms now employ significant ad sales staff based in DC to take advantage of congressional and presidential election cycles.

The former RNC official, who requested anonymity to speak freely about his past work on the 2016 election, noted that the last four years marked rapid progress in digital advertising from a time when Mitt Romney was toying around with Apple’s iAds and Facebook’s then-new mobile advertising platform.

“Technology didn’t catch up to our demand until this cycle,” the official said. “Google, Microsoft, Facebook, and Twitter offered stuff in 2016 that was light years ahead of eight years ago.”

Between 2012 and 2016, according to the research firm Borrell Associates, spending on digital political advertising from campaigns across the country increased by 789 percent to about $1.4 billion. The Trump campaign’s spend in the 2016 election on Facebook alone was at least $70 million, per the Washington Post.

To facilitate all of that new business growth, Silicon Valley consulted with academics, hired more political staff, and created specialized tools for politicians. Facebook, for example, created a “blueprint” that showed how political advertisers can reach “small town America” and “values voters,” according to BuzzFeed News.

“I’ve been doing digital stuff since the late 90s, I’ve seen it develop from nothing,” Chris Maiorana, a digital strategist for Mike Huckabee’s 2016 campaign, said to VICE News. “From the beginning of digital to where we are now, digital’s presence in the campaigns has grown, and the importance of the tools has grown.”