Pepsi sank what must have been hundreds of thousands — maybe even millions — of dollars into a TV commercial, and then decided to hide it in plain sight.

The beverage giant paid Fox last year to weave its flagship beverage into a three-episode storyline in “Empire,” the network’s smash music biz drama in which the average 30-second spot costs more than $500,000. As part of the deal, none other than Lee Daniels, the series’ co-creator, and writers from the show crafted a story arc in which one of the main characters, Jamal Lyon, works to win a Pepsi endorsement deal and the chance to do a Pepsi ad. That commercial surfaced in a distinctive ad break that contained only the Pepsi spot. It was as if the “Empire” episode in question never paused for a word from its sponsor.

“The 30-second spot is still very important to us and it will be for a very long time,” says Adam Harter, PepsiCo’s VP of cultural connections. “But it’s just not enough anymore.”

Pepsi often serves its soda in a bottle. Now it wants to catch lightning in one. If the maker of everything from Mountain Dew to Diet Pepsi has its way, more of these types of commercial pitches — indistinguishable, in a sense, from the program they accompany — could be on the way.

The company has good reason for pursuing the tactic. During the fourth quarter 2015, when the “Empire” integration ran, Pepsi sales rose 4.7%. “Our intention is to change the way brands and networks partner together,” says Harter. “We look at ‘Empire’ more as a first step, a very successful first swing at the plate, but it’s just the beginning, and we are looking for our partners, Fox and others, to continue that type of work moving forward.”

Across the set-top box, more TV networks are trying to accommodate that demand. Like Fox, they are experimenting with running fewer ads, then encouraging a winnowed slate of sponsors to devise commercials that tie back to the shows of which they are part.

This sort of stuff isn’t new, as anyone who was around to watch “Texaco Star Theatre” at the dawn of television can tell you, but it is taking on new urgency. If those trying it are successful, your favorite programs might deliver not only story, characters and catch phrases, but also a couple of ad pitches that are more difficult to discern than, say, a red cup of Coca-Cola on the judges’ table on “American Idol.”

Millions of dollars are at stake. Cutting back on ads makes for shorter commercial breaks. Creating commercials that echo the themes of the program that drew viewers to the screen in the first place makes for more interesting commercial breaks. At a time when viewership is splintering thanks to mobile devices and streaming video on demand, these gambits might just boost commercial ratings, the basis upon which Madison Avenue and TV networks set their payments.

Others believe the TV companies must make substantial changes to compete with newer viewing behaviors related to streaming video and mobile devices, where running fewer ads is an accepted practice. “It is critical for TV networks to make ads less intrusive. A key step to that is to have fewer of them. Another key step is to make sure the commercials themselves are better or add value to the viewing experience in some way,” says Brian Sheehan, a professor of advertising at Syracuse University. “This is the future, if they want to have one.”

As the start of TV’s annual upfront advertising market looms, several networks have unveiled surprising initiatives. NBC’s “Saturday Night Live” will reduce its ad load next season by 30% in the hopes of drawing more premium deals. TNT expects to run three new dramas with significantly fewer ads. TruTV, like TNT owned by Time Warner’s Turner unit, intends to run fewer commercials and more programming starting later this year. Viacom’s networks are trimming the number of ads they feature in primetime.

And there are offers to help blend ads with the TV outlet in which they surface. Fox Networks Group, A+E Networks and Viacom are all pushing new units that help advertisers tailor commercials to their particular products.

“One of the things we are constantly hearing from our clients is they want fewer, bigger, better partnerships,” says Alison Tarrant, exec VP of client partnerships at NBCUniversal. Advertisers want to identify content that truly interests their likeliest customer, then make sure their message is hard to miss, she says, “rather than spreading out among too many different partners.”

The ads are designed to make eyes pop. In December, for example, Target was the only advertiser when ABC broadcast the 1964 classic “Mary Poppins” as part of a special revival of “The Wonderful World of Disney.” Dick Van Dyke, one of the movie’s stars, held forth with Bullseye, the Target canine mascot, in a Disney archive warehouse in commercials that appeared during the show.

And yet, these commercials will never succeed alone. Big advertisers like Procter & Gamble, Unilever and Apple need to reach millions of consumers with regular messages in order to prod them to make purchases in stores or online.

At Fox, for example, there is more emphasis on aligning advertisers with shows across every possible screen: TV, online and video on demand. Time Warner’s Turner is ramping up its efforts to help advertisers create customized content in any number of venues, says Dan Riess, exec VP of content partnerships for Turner ad sales. “It’s really hard to scale if the content you are going after is specific to just one show,” he says.

TV has toyed with this stuff for decades. CBS went an unusual route in 2005 when it accepted $2 million from Philips Electronics to make it the sole sponsor of a single episode of “60 Minutes.” Philips in turn ran fewer ads during the program, and allowed the extra minutes to be used by the show for longer reports.

And during the seven-season run of “30 Rock” on NBC, showrunners Tina Fey and Robert Carlock would routinely work advertisers like Snapple and Verizon into the program, ensuring the product placements matched the tone of the show. In one particularly line-blurring example, a vignette featuring Chris Parnell as recurring character Dr. Spaceman touting the value of Dr. Pepper ran between the end of an episode and the listing of the production credits.

In the past, these were always experiments. Now network execs and Madison Avenue mavens are moving earnestly to adopt the techniques and make them more of a rule rather than an exception.

Will Pepsi get its wish this season? Most likely. But it will also have to continue buying ads and wrapping its pitches around the programming it thinks appeal most to its best customers. “We are never going to force things into places they don’t belong, but we will continue to look for those opportunities for clients in programming that makes sense and is a good fit,” says Toby Byrne, president of ad sales for Fox Networks Group.

The process of hammering out new models for advertising is never easy, but it may well be these kind of changes that keep networks healthy and marketers selling soap — and soda — to the next Pepsi Generation.