John Ellis, president of Optics For Hire, was dismayed to discover that ads for his engineering company were helping fund right-wing websites including one owned by white nationalist leader Richard Spencer. (Josh Reynolds/For The Washington Post)

Correction: An earlier version of this story said The Post sent an e-mail seeking comment to the website My Posting Career. The Post sent the e-mail to the wrong address. The Post did seek comment via a phone number affiliated with My Posting Career in a domain registration database but did not receive a response. This story has been updated with a comment.

As the owner of a small business in liberal Massachusetts, John Ellis was a natural sympathizer of the nationwide call for advertisers to boycott Breitbart News, with its hard-edge conservative politics and close ties to President Trump. But it made Ellis wonder about other, more extreme right-wing sites: Who is placing ads on them?

A few clicks around the Internet revealed a troubling answer: He was.

On a website owned by white nationalist leader Richard Spencer, Ellis saw an ad for his engineering company, Optics for Hire, pop up on the screen — even though he had never knowingly bought the ad.

What Ellis had stumbled on was a little-known facet of the booming world of Internet advertising. Businesses using the latest in online advertising technology offered by Google, Yahoo and major competitors are also increasingly finding their ads placed alongside politically extreme and derogatory content.

That’s because the ad networks offered by Google, Yahoo and others can display ads on vast numbers of third-party websites based on people’s search and browsing histories. Although the strategy gives advertisers an unprecedented ability to reach customers who fit a narrow profile, it dramatically curtails their ability to control where their advertisements appear.

“No one has any idea where their ads are going,” said Ellis. In some cases, he added, ad networks “are monetizing hate.”

In a sign of growing frustration, AT&T, Verizon and other leading companies this week pulled their business from Google’s AdSense network in response to news reports that ads had appeared with propaganda from the Islamic State and violent groups.

But the issue is broader. A Washington Post examination of dozens of sites with politically extreme and derogatory content found that many were customers of leading ad networks, which share a portion of revenue gleaned from advertisers with the site’s operators.

The Post’s examination found that the networks had displayed ads for Allstate, IBM, DirectTV and dozens of other household brand names on websites with content containing racial and ethnic slurs, Holocaust denial and disparaging comments about African Americans, Jews, women and gay people.

Some of these sites, the Post found, featured hateful and derogatory content throughout. In others, it was confined to comment sections, where users went far beyond the language used by the sites’ writers, whose expressed views fell closer to the political mainstream.

Google’s AdSense, for example, last month ran ads for several companies alongside comments using a slur for African Americans, saying “hang them all.” Other Google-displayed ads, for Macy’s and the genetics company 23andMe, appeared on the website My Posting Career, which describes itself as a “white privilege zone,” next to a notice saying the site would offer a referral bonus for each member related to Adolf Hitler.

“No business wants to be associated with sites like that,” said Andy Kill, spokesman for genetic testing company 23andMe. “If you’re trusting an ad algorithm to do this, this is what can happen,” he said. “It’s frustrating.”

A person identifying himself as Stephen J. Krune III, who is the registered owner of the My Posting Career domain name, called the site a “radical comedy forum” in a statement.

“MPC uses avant garde humor to tweak the political establishment in the long tradition of radical comedy,” the statement read. “MPC is anti-white nationalist, anti-white supremacist, and highly critical of Adolf Hitler.”

The problem has emerged as Web advertising strategies have evolved. Advertisers sometimes choose to place their ads on particular sites — or avoid sites they dislike — but a growing share of advertising budgets go to what the industry calls “programmatic” buys. These ads are aimed at people whose demographic or consumer profile is receptive to a marketing message, no matter where they browse on the Internet. Algorithms decide where to place ads, based on people’s prior Web usage, across vastly different types of sites.

The technology companies behind ad networks have slowly begun to address the issue, but warn it won’t be easy to solve. They say their algorithms struggle to distinguish between content that is truly offensive and language that is not offensive in context. For example, it can be hard for computers to determine the difference between the use of a racial slur on a white-supremacy site and a website about history.

The tech companies have also long been reluctant to put themselves in the position of an arbiter of speech — given the subjectivity involved and the legal risk of making decisions about what content deserves to be read or not. It’s a situation that tech giants are increasingly encountering in related spheres, too, with the proliferation of false and highly politicized news sites spreading misinformation on social networks.

On Monday, following inquiries from The Post and requests from advertisers who also had been contacted by The Post, Google apologized to advertisers. It announced it would be conducting an “extensive review” of ad policies with the goal of taking a tougher stance on “hateful, offensive, and derogatory content.”

Google said such comments violate its hate-speech policies but would not say whether it had taken action against the sites. The company said it reviews thousands of sites each day for violations and booted more than 100,000 publishers — including many single-author publishers — from its AdSense network in 2016.

Yahoo, which blocked one site that was the subject of a query by The Post, said it condemns racist or other hateful speech, adding, “Of the billions of ads served on a daily basis, there are rare instances when automated ad platforms serve ads in places they shouldn’t.”

(The Washington Post sometimes uses such networks to place ads touting its offerings, such as subscriptions, and also generates revenue featuring ads sold through advertising networks.)

Many of the companies contacted for this story — including IBM, bareMinerals, Macy’s, Everquote and Allstate — expressed surprise and dismay that their ads appeared near derogatory content.

Several said they had requested that networks blacklist those pages, which is easy to do for individual sites but not for entire categories of sites. Automated filters typically miss certain kinds of derogatory speech, and tech companies traditionally have not hired the massive number of people necessary to carefully monitor content on billions of Web pages.

Some advertisers also expressed frustration that ad networks had failed to keep marketing messages from appearing alongside reader comments that might upset customers — even on sites that themselves do not promote extremist content.

Google’s AdSense, for example, displayed an ad for cosmetics company bareMinerals in the comments section of Weaselzippers.us, an aggregator of conservative news. A user comment on the site used a derogatory word for gay men and said they should be “lying in a pool of blood.”

When The Post emailed an image of the Web page to bareMinerals spokeswoman Joanne Chiu Sulit, she said, “I was shocked that we were on that site.”

An email to the operators of Weaselzippers.us was not returned.

‘It’s whack-a-mole’

The issue of ad placements has become charged in an era of rising political polarization. The number of right-wing hate sites, as well as sites that traffic in sensationalist news and hoaxes, has doubled over the past year, according to ad auditing firm DoubleVerify.

With so many new sites, it’s difficult for advertisers to avoid having their ads appear in unwelcome places. “It’s whack-a-mole,” said Wayne Gattinella, chief executive of DoubleVerify. “You can flag keywords. You can use algorithmic decision-making to minimize it, but there is no way to filter the word choice in real time.”

Advertisers generally have little choice but to depend on ad networks. The major ones have policies prohibiting advertising on sites featuring discriminatory or hateful speech, but The Post found dozens of apparent violations. Many of the sites where The Post found violations are considered hate sites by the Southern Poverty Law Center, an advocacy group that tracks hate speech.

“[Ad networks] have rules in place but they don’t enforce them,” said Jillian York, an advocate with the Electronic Freedom Foundation, which runs Online Censorship, a program pushing technology companies to clarify why they remove content.

Last month, an ad for insurance company Allstate appeared on Alternative-Right.BlogSpot.com, whose comments section praised “Hitler and his National Socialists as a visionary.”

Allstate said it has tried to avoid such sites through filters. “Allstate does not knowingly advertise on media that provokes hate or includes threatening, discriminatory or offensive language,” spokeswoman Laura Strykowski said.

Everquote and DirectTV ads appeared on Spencer’s site, RadixJournal.com, alongside comments decrying the Catholic Church for advocating racial mixing and deluging white, Christian countries with “savages of the worst kind.”

DirectTV declined to comment. Everquote said that although it uses ad networks, “We specifically require that these advertising networks refrain from placing our ads on any sites containing and/or relating to, among other things, violence, sex, racism, sexism, pornography, illegal or potentially illegal subject matter, negative publicity or any other highly explosive subject matter.”

Ads for Macy’s, Amazon.com, and even Planned Parenthood, appeared on the racially inflammatory website My Posting Career. Ads to shop on Amazon.com appeared on a site with an article headlined “Yes, I am a Nazi,” and a comments sections peppered with profanity and racial slurs.

Amazon, which also runs an ad network, declined to comment. (Amazon chief executive Jeffrey P. Bezos owns The Post).

‘Crisis of our time’

Silicon Valley companies long have resisted calls to more aggressively police content on their platforms, saying a free and open Internet is the underpinning of the Web itself. With the exception of child pornography, Congress largely has agreed with the Silicon Valley viewpoint, leaving tech companies substantial legal leeway to monitor — or not — the content that appears on the sites and platforms that they operate.

But advertisers are demanding changes.

“[Tech companies] are struggling to adjust to a reality where the same tools that enabled them to connect the world are now being used to drive it apart,” entrepreneur and venture capitalist Noah Lichtenstein said. “This is the crisis of our time: How do you balance the desire to have the Web be open and connected with a rising tide of institutionalized hate and the protection of those who are being attacked?”

It’s not clear how effective the push to deprive such sites of advertising will be. Spencer said targeting Radix Journal and similar sites is unfair to advertisers because they have so little control over where their ads appear. And if the goal is to deprive extreme sites of money, he predicted the effort would have little effect because the revenue from Web ads is so small, totaling at most a few thousand dollars a year.

“If I were kicked off of all of these things, it would have no effect on my life whatsoever,” Spencer said.

Emails to contact information listed for Alternative-Right.blogspot.com received no reply. Breitbart News also did not return emails seeking comment about the advertising boycott directed against the site.

Disqus, a Silicon Valley start-up that manages comments sections for 4 million sites, including those for Breitbart News, Radix Journal and Occidental Dissent, sells advertising alongside the comments. It has been trying to work through the issues raised by inflammatory content, said chief executive Daniel Ha, adding that the company has been flooded with complaints about hate speech from users, advertisers and employees.

“User-generated content has always been extremely chaotic, and that’s part of what makes the Internet so amazing — you can share very unpopular ideas,” Ha said. “I think, however, that we’ve seen in the last year that there’s a bigger responsibility for how that affects society.”

The company’s terms and conditions prohibit instances of “extreme discrimination” on its comment boards, and a team of 10 reviewers makes the judgment calls. He said the line between “targeted harassment that feels violent” vs. someone making an off-color joke isn’t always clear.

In a blog post last month, the company announced a new tool that allows users to flag offensive comments. But the software is still largely untested.

Ha said he had blocked three of the extremist sites after being contacted by The Post. One of them, the neo-Confederate site Occidental Dissent, used the development to make a public call for more donations, earning what site founder Brad Griffin said was about $1,000 — several times more than the advertisements had produced in recent months.

“It worked out nice for me,” Griffin said.