President Trump stumped for GOP congressional candidates at a breakneck pace in the closing weeks of the midterms, crisscrossing the country to energize voters at his trademark ‘MAGA’ rallies.

But aside from lending a hand to Republicans in tight Senate races, those raucous rallies have served another purpose. Beneath the roar of the crowd and boisterous chants of “Build that wall,” a sophisticated operation by the Trump campaign and Republican National Committee was quietly building a voter database yet unseen on the political stage – one that will boost the party going into 2020.

“Their voter database is literally one of the most valuable databases in the world,” Republican strategist Alex Conant said.

The two organizations have a data-sharing agreement that allows them to communicate on everything from how to engage voters to where a rally could be held in any given state.

And those MAGA rallies have served as fertile ground for sign-up efforts.

'Their voter database is literally one of the most valuable databases in the world.' — Republican strategist Alex Conant

The RNC said a huge asset of the rallies is they attract a mix of voters: some who are politically active and others who may not have voted in decades. These so-called “low propensity voters” — defined by the RNC as those who have not participated in four of the last four elections — have been added to internal databases at rally after rally.

Here’s how it works: After attendees sign up with their contact information, the RNC will then match them to a voter profile and follow up with a mix of messaging. In the weeks leading up to the midterms, the RNC sent rally-goers texts the next day when they were still on a “rally high” -- with a link providing polling locations and voter registration efforts.

The RNC also said they've enlisted over 200,000 volunteers this election cycle, which they attribute to those rallies. That gives the party a powerful tool going into the president’s re-election effort and the next round of congressional races.

"If you show up to a Trump rally, there's a good chance the campaign can convert you into a donor or volunteer down the line,” Conant said. “Trump's team does an excellent job capturing data at all of their rallies and it will be invaluable in 2020.”

Republicans see immense opportunities in reaching out to these voters.

In Missouri, where Republican Josh Hawley defeated incumbent Democrat Claire McCaskill in a heated Senate race, fewer than half of rally-goers in both Columbia and Cape Girardeau had voted in all the past four elections. This pointed to how many untapped voters were available to them and where the president could perhaps find a persuadable audience.

“No one can energize and turn out voters better than President Trump, and the RNC is the best partner to help us identify these voters,” said Michael Glassner, chief operating officer for the Trump campaign. “This relationship was a difference-maker in 2016, key to our historic gains in the Senate in 2018 and will be crucial to our success in 2020.”

Along with Missouri, Republicans flipped Democrat-held Senate seats in Florida, Indiana and North Dakota. Despite losing in Arizona and Nevada -- and losing the House -- they finished the midterms with an expanded 53-47 Senate majority. The Trump rallies were a regular fixture in these states, with the president hitting the road multiple times a week in the post-Labor Day lead-up to the election.

Republicans describe these midterm operations as just the start of building their 2020 machine.

“The RNC’s data combined with the President’s unique ability to energize voters and boost turnout has been an undeniable force in helping get candidates in tight races across the finish line,” RNC Chairwoman Ronna McDaniel said. “Because of him, we defeated 4 Democrat senators, and we look forward to building on our successes as we head into 2020.”

Whether the energy can be sustained going into 2020 remains to be seen, but Trump is sure to keep holding rallies -- and officials said the losses the GOP did suffer in 2018, like in Montana where Democratic Sen. Jon Tester won despite Trump’s visits, will help them map out a better strategy for 2020.

Democrats, meanwhile, do not have an incumbent president to unify behind going into 2020 or a centralized series of rallies where casual supporters can be turned into activists. However, the party’s big House victories in November have emboldened progressive groups heading into 2020.

Many of these, like California billionaire Tom Steyer’s Need to Impeach effort, made voter registration part of their operation heading into the midterms. Steyer invested $10 million in August to engage the over 6 million people on his group’s list -- and specifically targeted the 64 percent of those identified as “infrequent” midterm voters.

A Democratic National Committee official said the party also has had a presence at events like March for Our Lives — the protest about school safety and gun violence in wake of the shooting at Marjory Stoneman Douglas High School earlier this year — though they are not directly affiliated with the movement.

Former Trump campaign strategist Michael Caputo, however, claims that Democrats won’t be able to keep up with the president’s operation.

“The president’s data gain in 2020 is going to make 2016 look like child’s play,” said Caputo. “Democrats have absolutely zero chance of matching this asset.”