AMITYVILLE, N.Y. — Liuba Grechen Shirley, the long-shot Democratic challenger in New York’s 2nd Congressional District, has an improbable story, two enchanting children, and a snug century-old farmhouse — the perfect ingredients for a viral political ad in 2018.

On an impossibly humid summer day, an eight-person film crew crowded into her Long Island home, along with her campaign staff, her mother and a wilting menagerie of pets to create Grechen Shirley’s first professional video.

“I’m trying to make this look normal,” said Grechen Shirley, 37, while the Steadicam was rolling, 2-year-old Nicholas on her hip. “But it’s not normal. And it’s 700 degrees in here.”

Ten hours of shooting would eventually be winnowed to a two-minute, 45-second video, opening with an artful 90-second tracking shot through her home that, on its own, is three times the length of a typical TV spot. It’s an impressionistic portrait of her middle-class life: Nicholas on his hobby horse, sun glinting through kitchen windows, the campaign staff manning laptops in her toy-cluttered dining room. The candidate changes into heels as a swelling New Age soundtrack sweeps you into Americana images of her district, so many flags and hugs.

But this video was not created for TV. Instead, the ad (tag line: “This time it’s personal”) launched Aug. 15 via Facebook, Twitter and YouTube.

This is how a candidate introduces herself in 2018 — through videos with the narrative sweep of a short film, the intimate scale of a smartphone screen, and the DIY frugality of social media.

Candidate spots were once filmed in offices or on sets, narrated by stentorian-voiced actors, buffed with a hermetic Madison Avenue sheen. The new generation of digital ads celebrates the quotidian — homes, kitchens, even bathrooms. They showcase the earthy side of politics, tireless candidates pounding streets and doors. They emphasize feelings, tears, hugs and more hugs. They remind you of an ad for that character-driven Netflix series you’ve been meaning to check out.

Grechen Shirley had a lot riding on her $30,000 ad. As a first-time candidate in this crimson swath of Long Island, she needed to get her name and story out to voters and potential donors — not only regionally but perhaps nationally.

In the old days, which is to say a couple of election cycles ago, “you either had $3 million or you shouldn’t go up in New York,” said her political strategist, Bill Hyers. Grechen Shirley didn’t have $3 million. But the right kind of digital ads allow candidates to launch themselves for far less — if they manage to go viral.

Alexandria Ocasio-Cortez’s “Courage to Change” video was viewed almost 1 million times before her upset victory over Rep. Joseph Crowley (D-N.Y.) in the June primary, according to its creators; it has since crossed the 5 million mark. In the days immediately after the video’s release, donations to her campaign increased tenfold.

The $10,000 ad was the first candidate video by the Michigan-based team of Naomi Burton and Nick Hayes, who had previously crafted issue spots. It calls to mind a film-student project: occasionally blurred and harshly lit shots at unconventional angles, sweeping through the streets of her district, paired with a techno soundtrack, to illustrate Ocasio-Cortez’s determination.

“We didn’t want to get lost in the artistic,” Hayes said. “We wanted it to be in­cred­ibly accessible, and stress the everyday of who she is.”

Grechen Shirley also scored a primary upset over a more experienced party leader, but she remains an undeniable long shot going into the general against 13-term GOP Rep. Peter T. King, who in 2016 won the district by 24 points.

She needed to make some noise.

“I’m not going to be happy with less than a million views,” said her ad creator Matt McLaughlin, standing in Grechen Shirley’s crowded kitchen. He has produced videos for Bill de Blasio and Cynthia Nixon, but it was his ad for Randy Bryce, the mustachioed Wisconsin ironworker hoping to flip retiring Speaker Paul D. Ryan’s House seat for the Democrats, that solidified McLaughlin’s credentials as a viral savant. The ad — a haunting violin-scored mini-film that opens with Bryce recounting his mother’s struggle with multiple sclerosis — became an immediate sensation last year from the moment comedian Chelsea Handler tweeted it.

That’s what Grechen Shirley wanted from her ad. “I want it to go viral,” she said; 4 million views was her goal. “And I want it to explain who I am — like the MJ Hegar ad.”

Ah, yes, “Doors.” The “Hamilton” of viral political ads.

In the now-legendary 3½ -minute spot, Hegar — an Air Force vet and tattooed mom challenging an eight-term incumbent for a Texas congressional seat — recounts the helicopter crash she survived in Afghanistan and her stateside battle to lift restrictions on combat roles for women, while the camera swoops and swerves fluidly through chapters of her life. A taut guitar riff, loosely borrowed from “Gimme Shelter,” amps up the tension.

It’s fairly irresistible: Since its June release, the spot’s been viewed more than 5 million times. It helped Hegar — who remains a long shot against Rep. John Carter (R-Tex.) — raise $750,000 in 10 days, mostly from out of state.

Its creator, Cayce McCabe, is a senior vice president at Putnam Partners, a firm of Democratic ad makers whose founder, Mark Putnam, crafted the super-viral 2016 ad for Jason Kander showing the Afghanistan war veteran holding forth on gun rights while assembling an AR-15 rifle blindfolded. The Missouri Democrat lost his U.S. Senate race but was launched as a rising star.

Viral ads are narrated by the candidate. There’s an absence of snark. Tracking shots — of subways, grain fields, iron works, depending on the district — are deployed to convey the challenger’s swelling momentum. Much of the magic, and time invested, happens in editing.

“What I love about the longer form is it feels less like a political ad and more like a story. You can tell a full story, which is really tough to do in 30 seconds,” McCabe says “You can do something attention-getting.”

They aren’t necessarily cheaper to make than conventional ads — “Doors” cost around $45,000, McCabe said — but campaigns are spared the costly television buys.

Social media platforms have emerged as the primary means of circulating candidate ads, said Vanderbilt political science professor John G. Geer, because they’re already dominating the political conversation. And between cord-cutters and DVR-dependents, who’s watching television ads anymore?

McCabe says it’s no coincidence that voters are finding these ads on YouTube, Facebook and Twitter — the same places they are drinking up all kinds of depressing sagas. “These stories fill you with hope about people pushing back,” he said. “You’re giving people something positive on the same platform.”

Viral ads have been particularly big among Democratic women — though Iowa Republican Joni Ernst soared to fame and a 2014 U.S. Senate victory with the much-circulated spot where she promised her experience castrating hogs would help her “cut pork” in Washington. If these kinds of ads succeed in getting Democrats elected this cycle, Geer said, “I can guarantee Republicans will start making more of them.”

Grechen Shirley wasn't a fan of the script that had been prepared for her ad. She dutifully read it many times in her cramped upstairs office/TV room but felt it wasn't her. And the idea with these ads is to seem unscripted, even when they aren't.

They also eschew the voice-of-God narration of an earlier era of political advertising to let the candidates themselves do the talking. Hegar even broke the fourth wall in her ad, stopping the action to speak directly to the camera, as if in an edgy sitcom.

“These ads strike me as ‘let me introduce you to myself,’ ” said Wesleyan professor Erika Franklin Fowler. “They’re quirkier, funnier, with a twist” — which is a welcome change, she added. “Americans tend to associate politics with negativity, so these positive ads do have an effect on the perception of the candidate.”

And anyway, Hyers maintains that going negative won’t work. “This election year is about enthusiasm,” he said, “and this [ad] is a first step in getting people enthusiastic.”

Grechen Shirley ended up taking the talking points of her original script and recasting them in her own words.

Ultimately, her video did precisely what she and her team hoped, reaching 921,000 voters in the first two weeks, primarily through Facebook.

It also helped attract media attention. “She’s Trying to Pull an Ocasio-Cortez. Her Target: Pete King” read the New York Times headline two days after the ad launched. The story noted that Grechen Shirley’s web spot evoked the Ocasio-Cortez one, with its “stirring music and polished editing.” The FiveThirtyEight polling and prognostication website shifted New York’s 2nd District race from “solid Republican” to “likely Republican.” A granular distinction, but Grechen Shirley was over the moon.

Her entire career has been spent working for nonprofits. “My kids were 1 and 3 when I decided to run,” she said. She was standing on her sun porch, taking a lunch break from filming to hang out with her children, clad in wet bathing suits. “Who in their right mind runs for elected office when their children are 1 and 3?” she laughed.

If only the camera had been rolling.

An earlier version of this story stated that Cayce McCabe created Jason Kander’s 2016 campaign ad. The creator was Mark Putnam, founder of McCabe’s firm, Putnam Partners.

Nadine Ajaka contributed to this report.