Online advertising's been built around the ability to know exactly who you are. Are you a guitar-playing, cat-owning botanist? You'll get served ads for guitar-shaped catnip hedge grow kits. Google, Twitter, and all other digital platforms where an advertisement can be served—with Facebook leading the charge—want to know everything about you, usually already do, and use that information to convince marketers that the ads you'll see are perfectly targeted to whoever you are (or aren't).

That's an intense stripe of power. And maybe that's fine—even, potentially, helpful—when advertisers are dividing people by shopping habits, or hobbies. But when it comes to identifiers like race or ethnicity, that targeting can devolve into discrimination that cements harmful societal norms. At worst, it can perpetuate blatant prejudice that can affect critical issues in our lives, like housing and hiring.

On Friday, Facebook finally admitted it'd been on the wrong side of that line. The company said it would stop allowing advertisers to exclude certain "ethnic affinities" in categories like jobs and housing.

The ability to exclude people by "race" will still be available for the vast majority of Facebook advertisers, though. Facebook still claims this is too useful of a tool to kill—that the upside of it outweighs the downside.

Others aren't so sure.

The entire fracas is just the latest in a running series of incidents of online discrimination that are even more subtle than Facebook's situation. The quiet discrimination of online advertising raises questions about the fairness of targeting users via personal data-points, and the lengths marketers are willing to go do so.

It's a dilemma that ties back to one of the biggest challenges that's always faced the ad industry: How do you sell to society in specific ways without reinforcing our ugliest tendencies?

Ethnic 'affinities'

An October 2016 ProPublica investigation found that the way Facebook packages users could violate civil rights laws that ban discrimination in housing ads.

They discovered an option within the platform that lets brands cater to (or exclude) people by ethnic affinity—in other words, users the company's judged to have a distinct predilection for African-Americans, Asian-Americans, Hispanics or other racial groups.

Facebook countered that the tool looks for "affinity" rather than a stated race, and thus, doesn't break laws governing ad discrimination.

John Relman , a prominent civil rights lawyer, emphatically disagreed when ProPublica plied him with the same question.

"This is horrifying. This is massively illegal," he told the outlet. "This is about as blatant a violation of the federal Fair Housing Act as one can find."

The site also pointed out how the options appear under Facebook's "demographics" heading, to which the social network replied that it had plans to switch their category. Of course, Facebook eventually made the absolute minimum changes needed to stay inside the law.

When machines discriminate

Not every example of ad discrimination is as blatant as Facebook's.

Sometimes bias is the consequence of cold machine learning. Algorithms evolve and find patterns on their own that might fly in the face of what their creators intended. Researchers at Carnegie Mellon University, for instance, found last year that Google ads tended to show far fewer women than men job offers for positions with salaries of $200,000 or more.

More troubling yet, Google-hosted job listings in STEM fields also disproportionately sought out males.

An ad tech firm helped researchers trace the decision-making process back to a so-called "black-box" system—an opaque targeting script with little human supervision or input. That combined with the audiences advertisers input into the program produce the results.

"There's really very little transparency into how these decisions are getting made and whether there are societal values either intentionally or unintentionally being compromised in the process," says Anupam Datta, a computer science professor who helped build the software responsible for the findings.

It's unclear whether the algorithm observed traits or tendencies in Google's cache of user data that led it to act this way, or if it was a function of its programming or inputs from marketers.

A Google spokesperson said in a statement that the company follows strict policies that govern how ads are targeted.

"Advertisers can choose to target the audience they want to reach, and we have policies that guide the type of interest-based ads that are allowed," the spokesperson said. "We provide transparency to users with 'Why This Ad' notices and Ad Settings, as well as the ability to opt out of interest-based ads."

While no laws were broken, the process illustrated how easily self-teaching programs can end up reinforcing, say, the gender pay gap, and stereotypes about which professions are supposedly more suitable for women or men.

These kinds of biases can manifest in more latent ways, too. Shades of sexism like gender-coded language or postings soliciting someone who's the "right fit" might be amplified by perceptive artificial intelligence.

The problem there? The tools with potential for discriminatory abuse are the same ones needed for legitimate efforts to rope in diverse communities.

"In advertising you're trying to reach out to specific groups," says Wendy Stryker, an employment lawyer at New York law firm Frankfurt Kurnit Klein & Selz. "How do you do that without violating some of these [discrimination] laws?"

Stryker says there are clear laws dictating what constitutes discrimination in advertising to job applicants, as there are for home-seekers. As the above case shows, those rules don't always account for everything.

Racist searches

"Have you ever been arrested?" Harvard data privacy professor Latanya Sweeney begins her powerful 2013 study, examining how ads placed on Google and Reuters treat race. "Imagine the question not appearing in the solitude of your thoughts as you read this paper, but appearing explicitly whenever someone queries your name in a search engine."

In her research, Sweeney found that searches for "black-sounding" names turned up significantly more sponsored results and display ads mentioning things like criminal records and background checks than others.

A Google spokesperson denied that the search engine does any sort of racial profiling, pointing to a policy that bans advertisers from advocating against any one group or subset of people. Background check site Instantcheckmate.com, one of the primary brands named, also swore it didn't use any technology that could connect name to race.

If Sweeney's right, her findings demonstrate a particularly egregious instance of prejudice. Yet, such problems also connect back to a defining dilemma that's plagued socially-aware advertisers for years: Advertising has always been caught between reflecting and advancing the culture from which it feeds.

Advertising, by nature, plays off of sometimes-stale generalizations and group commonalities in order to better appeal to specific parts of the population, leading to a reputation as "the most prevalent and toxic of the mental pollutants," in the words of Canadian activist Kalle Lasn.

But more groundbreaking work can also change societal perceptions and split open otherwise untapped markets. For instance, efforts like a Spanish-language campaign geared towards Hispanic web surfers—the kind of diversity outreach for which Facebook says its race tools were rightly intended.

On the web, where all ads are hyper-personal, and privacy's something of an illusion, the contrast between marketers' intentions and practices are intensified so much more than they are outside of the digital realm.

But the responsibility ultimately falls on Facebook to design targeting tools in a way that enable diverse advertising while preventing the more insidious abuses it might enable. And on Friday, Facebook took a step—however minimal—towards addressing that challenge. The question remains: What else, if anything, will they do about it?