On St. Patrick’s Day, executives at ad buying giant Havas filed into their London offices for another day at work — and discovered some very unpleasant news.

Ads that they had paid Google to place across its many digital properties were popping up attached to videos from some of the Internet’s most active hate mongers — including white nationalists such as David Duke, animal-rights extremists and ISIS.

They were not happy.

One ad, for Oracle and NetSuite, featuring smiling office workers, was displayed prominently on a video of two men carrying an ISIS flag. Another, for Walmart, sat atop a masked man crouching with fierce dogs.

While the ad world has long harbored resentment toward Google for its secretive ways, the videos were more than Havas could stomach. Havas’ UK boss, Paul Frampton, immediately yanked all of his clients’ commercials from the web giant.

“We have a duty of care to our clients in the UK marketplace . . . where we can be assured that that environment is safe, regulated to the degree necessary and additive to their brands’ objectives,” Frampton said in a statement.

Days later, Google apologized and promised to fix the problem — but it wasn’t enough. Within a week, AT&T, Johnson & Johnson, PepsiCo, Wal-mart, General Motors, Starbucks, Verizon, JPMorgan Chase and other mega-advertisers had followed suit, pulling their ads from Google’s platforms in the US.

It was a moment of reckoning for Google. After years of happily banking ever-expanding ad budgets, the world’s second-biggest company was on notice.

Google, the search engine, and its subsidiaries like YouTube have always insisted that they are simply a platform that serves content or ads. But suddenly that excuse wasn’t cutting it anymore.

“They’ve always maintained they were sort of digital engineers standing there with their digital [wrenches], trying to tighten the nuts on their digital pipes and not being responsible for the content that was going through the pipes,” Martin Sorrell, chief executive of the WPP Group, the biggest advertiser in the world with $102 billion in client ad money, said on CNBC.

But after the Havas snafu, “They can’t just say, ‘Look, we’re a technology company, we have nothing to do with the content that is appearing on our digital pages.’ ”

In fact, many industry leaders are now charging that Google and other tech giants, like Facebook, aren’t just web platforms; they’re publishers — like a news organization or a TV network — and they must shoulder the responsibility that comes with that role. “We have always said Google, Facebook and others are media companies and have the same responsibilities as any other media company,” Sorrell said.

With brands including Google Maps and its Gmail service, Google has a market cap of $562.4 billion and it controls 41 percent of the $83 billion US digital ad market. (Facebook controls 14.7 percent of the US digital ad business, according to eMarketer.) But its once-impenetrable brand equity is now in danger of evaporating, at least with a growing band of major advertisers.

They can’t just say, ‘Look, we’re a technology company, we have nothing to do with the content that is appearing on our digital pages.’

Traditionally, marketers spend considerable time and energy ensuring media outlets don’t run their ads next to clashing content. Fast-food ads, for example, are expected not to run alongside stories about dieting or diabetes. Airlines typically tell TV news outlets to drop their ads from breaks when plane crashes are reported.

But online? It’s a whole other story. There are few checks and balances.

Google argues it can never guarantee where ads land, because it’s contending with 400 hours of content uploaded every minute. Google also operates YouTube, one of the biggest destinations online offering advertisers a billion hours of viewing content per day, and a global ad exchange called DoubleClick, which automatically serves up ads on millions of websites all over the world.

Because of its size and dominance, for a long time Google called the shots. While other, less-important outlets were forced to provide advertisers with data that showed whether or not their online campaigns were effective, Google has long refused to share those metrics.

The company’s algorithm, which it uses to filter out unsavory content when placing ads, is also secret. But now it’s also clear it doesn’t work. The Times of London was the first to reveal Google’s glitch, with an investigation earlier this month exposing the Havas problem and setting off the advertising boycott.

Google’s response to the Times of London’s findings only seemed to compound the problem. On Monday, Google’s European chief, Matt Brittin, told advertisers at a conference that the company already had the tools to keep their ads off bad content, they just weren’t using them correctly. He added that Google would step in to help them figure it out and claimed that 98 percent of flagged content is reviewed within 24 hours.

(But after flagging several bad ad placements to Google that weren’t rectified within the 24 hour period, the Times of London proved this wasn’t entirely true.)

By Tuesday, Google Chief Business Officer Philipp Schindler, in a blog post, pledged to do more: “We know advertisers don’t want their ads next to content that doesn’t align with their values. So, starting today, we’re taking a tougher stance on hateful, offensive and derogatory content,” he wrote.

“In cases where advertisers find their ads were served where they shouldn’t have been, we plan to offer a new escalation path to make it easier for them to raise issues.”

Meanwhile, Eric Schmidt, the executive chairman of Google’s parent company, Alphabet, has been unable to promise a zero-tolerance policy. Appearing on Fox Business on Thursday, Schmidt stated that while Google “can get pretty close” to making sure ads won’t appear next to extremist content, he can’t guarantee it.

And now the damage may be too big to contain.

In May, big digital players including Google, Facebook, Snapchat, Twitter and AOL/Yahoo will start pitching their business as part of the “Digital New Fronts” — where marketers aiming to advertise the upcoming TV season commit the majority of their budgets to web outlets.

In the coming weeks, as Google hopes to grab TV ad budgets, execs will likely be spending most of their time discussing issues of brand safety, notes Pivotal Research analyst Brian Wieser.

Advertisers spend about $70 billion on TV ads in the US, and Wieser estimates Google could lose as much as $1 billion in new ad money as a result of the boycott and its aftermath. “Google’s stated solution was late and woeful. Given numerous opportunities to nip it in the bud, they’ve seemingly made it worse.”

Wieser said Google is “attempting to minimize the problem rather than eliminating it. We think that Google will probably need to articulate goals that sound more like a zero-tolerance policy, to alleviate concerns before it can fully recover.” On Monday, Wieser showed his lack of confidence in Google stock, downgrading Alphabet from a buy to a hold. By Friday, Alphabet stock was $814.43, losing $35 per share in a week.

While Google has allowed hate-speech content to run riot on its platforms, it is also accused of restricting ad funds to legitimate websites.

Israel-based Matan Uziel runs a serious documentary series on YouTube featuring women discussing rape and abuse. It includes, among other subjects, ex-models discussing how they became bulimic working in the fashion business. He says his organization supports Emma Watson’s UN initiative, “HeForShe.”

Uziel says Google served ads to his channel on YouTube until December, when suddenly the company halted the flow.

Uziel says he’s complained to YouTube that his female-empowerment series has been prevented from monetizing the clips in the “Real Women, Real Stories,” online series.

He pointed out that videos glorifying drugs and showing self-harm are able to monetize their ads, perhaps because the content of the ads isn’t so obvious to Google’s algorithm. He says he has called on YouTube CEO Susan Wojcicki to address the problem but got no response.

“It is a dark time in the US for women,” Uziel said. “Google owns YouTube and, like any multinational tech company, they are supposedly acting in their own best interests. But they are undermining their creators.” (Google declined to comment on Uziel’s claims.)

Stunned by the volume of complaints from major advertisers, on Friday Google issued a client memo detailing the changes it is making. The firm is promising to use a new type of artificial intelligence to flag inappropriate content that will even pick up a T-shirt bearing bad language, according to Bloomberg, which obtained the memo. It will also retool a video verification process and create a staff hotline to respond to complaints.

Google said it would implement changes by Sunday.

But some are saying Google needs to go even further, hiring actual human editors who can judge the nuances of content more effectively than an automated system. Google’s many rivals in the space, including AppNexus and AOL’s Marketplace, note that they have much tighter policies on what’s acceptable. “They need to hire more data scientists,” said one digital ad executive.

Critics say Google, which was cooked up nearly 20 years ago in a Menlo Park, Calif., garage by two college kids, Larry Page and Sergey Brin, is finally having to grow up, take responsibility for its content and deal with the issues that old-school publishers have long had to face. “It’s a shame it took this kind of a pressure,” one digital advertising executive told The Post.

Jon Bond, a veteran ad exec who works with In-N-Out Burger as co-chairman of ad agency holding company Shipyard, added that technology companies’ insensitivity to people is a huge weak point.

“Google isn’t about people, and that’s going to bite them,” Bond told The Post. “They’ve never had to go to a meeting where something inappropriate got blown up by the press and consumers wrote letters to the CEO.”

He said Google needs to fine-tune its artificial intelligence so that it has more of a human touch. “It’s impossible to be perfect. People aren’t perfect in the print world. But there is an acceptable range and they have to get closer to where the publishing world is — where it’s humans making decisions.”