What was different was that he also came up with some creative stats for someone else’s rally: the former Texas congressman and potential Democratic candidate Beto O’Rourke, an El Paso native, who spoke at a counterdemonstration against the president’s immigration policies. The president told his faithful that Mr. O’Rourke was speaking to “200 people, 300 people” — though unofficial estimates of the crowd ran well into the thousands.

I will leave it to others to adjudicate whose was bigger. But the night was an example of how nothing threatens this TV president more than a challenge to his ratings.

By holding a rally in Mr. O’Rourke’s home base, the president gave him the chance to do what few political opponents have managed since 2015: to split-screen him.

On cable news and in the morning-after coverage, there was a competing image to Mr. Trump’s MAGA-hatted arena throng: a “Monday Night Lights” assembly of protesters crowding a baseball field as Mr. O’Rourke, gesturing animatedly in shirt sleeves, insisted that the city was “safe not because of walls but in spite of walls.”

Potentially as significant as what Mr. O’Rourke said was that he managed to share billing with the president on TV. He benefited, of course, from Mr. Trump’s serving as his location scout and delivering him a made-for-cable-news opportunity. But his audience was not the only one that the ratings-hound-in-chief has been watching warily.

After California Sen. Kamala Harris began her campaign in front of more than 20,000 people in Oakland, the president mispronounced her name in an interview with The Times but took note of her “better crowd, better enthusiasm.” He was less kind to Sen. Elizabeth Warren, mocking a viral Instagram video of her cracking open a beer on New Year’s Eve, and Sen. Amy Klobuchar, whom he critiqued for kicking off her campaign outdoors in a Minnesota snowstorm.

But as someone once wrote in “The Art of the Deal,” “from a bottom-line perspective, bad publicity is sometimes better than no publicity at all.” Mr. Trump won the presidency in part by cornering the market on publicity — much of it bad, but all of it feverish.

The battle to succeed him in the White House will be, in part, a battle to succeed him as the protagonist of our national serial drama, which makes the primary, in part, an audition. It’s easy to imagine Mr. O’Rourke’s border standoff as one in a series of proxy battles to prove the candidates’ media-worthiness.

I know: It is demeaning and depressing to describe the American electoral process as a TV show. Nonetheless it is also true, as proven by the White House’s current occupant. (And not only by him: It was not for nothing that Republicans anxiously tried to dismiss Barack Obama in 2008 as a “celebrity.”)

And while getting media attention is not the same as making policy, it’s not irrelevant to that, either. Alexandria Ocasio-Cortez has gotten almost-unheard-of political influence for a first-term representative in part by being a media star — which is to say, by personifying a narrative, in TV and social media, of a counter-movement further left, more inclusive and younger than Mr. Trump’s own.

Taking on the president in the media doesn’t have to mean imitating him, down to the insults and the Twitter fights. But it does mean being able to seize attention with an alternative story, and sense what the camera is hungry for. To take down the No. 1 show in the country, you need to be an effective counterprogrammer.

That happens all the time in showbiz. In the president’s protesting-too-much theater criticism of his potential opponents, there’s a hint of the aging celeb’s fear of being overtaken by the next hot sensation — someone dynamic, younger or newer, who will catch and hold the camera’s roving eye. (This may have been the subtext when he told a West Virginia rally that he worries only about “some total unknown.”)

Mr. Trump has become yesterday’s news before. In the 1980s, he was the braggadocious public face of Reagan-era capitalism, dominating tabloid pages and talk shows; by the 1990s, he was a self-parody, doing ironic cameos on sitcoms like “The Fresh Prince of Bel-Air.”

For one season, “The Apprentice” was a pop-culture sensation that made him the toast of a grateful NBC; within years, the ratings dwindling and the public bored of the show’s overexposure, he was hosting a farcical, less-popular “celebrity” version.

As president, of course, he has the advantage of real power, and a press still fixated on “What will he tweet next?” coverage.

But as his nervous eye on his opponents’ crowds indicates, he knows that fame is powerful and fickle. And if it turns, you can fudge and spin your numbers, but the ratings don’t lie.