Donald Trump blamed the internet and social media for the “racist hate” displayed by the suspect in the El Paso massacre, but his own re-election campaign has characterized immigration as an “invasion” in more than 2,000 Facebook ads this year.

The president said the internet provided a “dangerous avenue to radicalize disturbed minds” on Monday, in his first public remarks about the mass shootings that left 22 dead in El Paso, Texas, and another nine dead in Dayton, Ohio, over the weekend.

“The shooter in El Paso posted a manifesto online consumed by racist hate,” he said. “We must shine light on the dark recesses of the internet, and stop mass murders before they start.”

The white nationalist screed by the suspect in the El Paso shooting was indeed posted in one of the those dark corners of the web: the extremist message board 8chan.

But the language used by the alleged killer replicates language used by Trump, and his re-election campaign, not in any obscure forum but on his official Facebook and Twitter pages. The second sentence of the manifesto – “This attack is a response to the Hispanic invasion of Texas” – echoes white nationalist rhetoric falsely asserting that people of Latino or Hispanic descent represent an “invasion” in the United States. Trump has used similar language on numerous occasions.

Trump’s campaign has used the word “invasion” to describe migrants seeking entry at the US-Mexico border in 2,199 Facebook ads since January, according to a Guardian analysis of Facebook’s political ad archive. Those ads have been viewed between 1,059,000 and 5,559,801 times by Facebook users and cost the Trump campaign between $7,900 and $241,601 to promote. (Facebook reports spending and performance of ads as a range.)

Facebook Twitter Pinterest Screengrabs of Trump’s Facebook ads. Photograph: Facebook

There are dozens of variations on the video clips in each ad, but just two variants of the copy.

The first version reads in part: “The crisis at the Southern Border is even worse than most understand. I have taken MULTIPLE trips to the border to show the true invasion happening but the Democrats and the Fake News Media just won’t listen. THE TIME IS NOW. WE NEED TO SECURE OUR BORDER! Nancy and Chuck have made it clear that they don’t want to know your opinions on how to keep America safe. They don’t want to know why you want the wall. But I do.”

This ad copy was used with different short videos, including one with a voiceover from Trump saying, “Liberals care more about illegal immigrants than they do about our own citizens. It’s time to put America first. We need border security,” playing over what appears to be footage of migrants running toward the border wall.

Trump has spent more than $8.7m on Facebook advertising this year. Photograph: Facebook

The ad encouraged users to click on an “official secure the border survey”, which then asks users to provide their contact information and identify their top concerns about the border from the following list: “Drug trafficking, criminals, MS-13 gang members, sex trafficking, illegal aliens, terrorists, all of the above.”

The second version of ad copy reads in part: “We have an INVASION! So we are BUILDING THE WALL to STOP IT. Dems will sue us. But we want a SAFE COUNTRY! It’s CRITICAL that we STOP THE INVASION. Nancy Pelosi and Democrats have not negotiated in good faith to fund a wall at our Southern Border, proving that OBSTRUCTION is far more important to them than YOUR SAFETY. I cannot allow America’s safety and security to be put at risk any longer. We need the wall, and I must put AMERICA FIRST!”

These ads ran with various short videos that largely used dark and foreboding music over dark and moody images, including a series that featured pixelated images of concertina wire against a dark sky, with the slogan: “America’s safety is at risk. This is a national emergency.”

These ads linked to a fundraising page rising money for Trump’s campaign.

The “invasion” advertisements appear to have been most successful among older women. Of the 372 versions of the ads that received at least 1,000 impressions – a figure referring to the number of people who see an ad – Facebook’s data revealed that 175 (47%) garnered the most impressions from women older than 55. Young men (between 25 and 34) and middle-aged men (between 55-64) were the other groups most likely to have been shown the ads. These demographic results are based in part on how a campaign chooses to target its ads and in part on how users respond to them.

The most successful of the “invasion” ads ran on 23 January with the second version of the copy. It was viewed by between 100,000 and 199,000 Facebook users, of whom 23.7% were men aged 25 to 34 and about 8% were from Texas. The Trump campaign spent between $500 and $999 to promote the ad.

Facebook pulled the caravan ads amid public outcry, but not before they were viewed by at least a million people. Photograph: Facebook

The threatening tenor of these ads is not unusual for Trump’s social media campaign. Since the beginning of the year, Trump has spent more than $8.7m on Facebook advertising, much of it designed to inspire outrage or fear. Other frequent topics include the border wall, “fake news” and “socialism”.

Another noteworthy ad campaign addressed the migrant “caravan” from Central America that became a fixation of conservative cable news and politicians as it traveled through Mexico in the weeks before the midterms. The ads did not include the word “invasion” in the copy, but did use it in a video voiceover, which said: “America cannot allow this invasion. The migrant caravan must be stopped.” The set of six ads were launched on 5 November 2018 – the day before the US congressional elections.

Facebook pulled the ads amid public outcry, but not before they were viewed by at least a million people. The video spot was also pulled from NBC and rejected by Fox News and CNN.

The group most likely to have seen the caravan ads on Facebook before they were removed was men aged 25-34 in Florida and Arizona.

Since Trump’s remarks on Monday morning, the set of approximately 1,000 Facebook ads his campaign is running have focused on selling campaign merchandise, including plastic straws, beer cozies and baseball caps. He is also running 28 ads featuring the slogan “Latinos for Trump”.

Peter Andringa contributed reporting