The digital ads from antiabortion groups appeared on the smartphones of young women who were near reproductive health clinics.
“You Have Choices,” one message said. Others offered “Pregnancy Help,’’ and assured recipients, “You’re Not Alone,” according to Massachusetts Attorney General Maura Healey, who on Tuesday announced a legal action that alleged the ads illegally used consumer health data.
A settlement reached with Healey’s office preemptively bars the company that devised the marketing campaign, Boston-based Copley Advertising, from sending such messages. It says the company cannot use location data about people who are near a Massachusetts health care facility to send them advertisements based on a medical condition.
The agreement raised First Amendment concerns among some observers and also drew attention to the fairly common ability of advertisers to use smartphone data to track locations and infer personal details about cellphone owners.
In this case, Copley Advertising used a technique known as “geofencing” that aims messages at cellphone users inside a certain geographic area. Those ads specifically targeted young women at or near reproductive health clinics, Healey said.
“We can reach every Planned Parenthood in the US,” Copley Advertising chief executive John F. Flynn said in a presentation posted on his Twitter account in 2016. “Copley Advertising can drill down to age and gender.’’
The ads could even follow women after they left the clinic, showing up on their cellphones for as long as a month, Flynn said.
One campaign was aimed at women 18 to 24 years old who had been near 140 abortion clinics in five cities, Flynn wrote in his presentation. The campaign delivered 2.4 million ad “impressions” and 10,000 “clicks,” he said.
Copley hasn’t run such ads in Massachusetts, but Healey said the practice essentially used confidential medical information to target people without their consent and had to be headed off.
“We wanted to be clear with this company. You’ve engaged in this practice in other places. We don’t want to see it here in Massachusetts,” she said.
Copley Advertising, a one-person firm founded in 2015, said in a statement that it hadn’t broken any laws and believed the campaign was protected by the First Amendment.
“We made an agreement with the A.G.’s office so we can devote our time and resources to working for our clients,” the company said on its website. “Their right to free speech should not be marginalized because government officials do not agree with the message of their advertisement.”
The two organizations that Healey said were behind the antiabortion ads, Bethany Christian Services of Michigan and RealOptions of California, did not respond to requests for comment on Tuesday.
Location-specific mobile ads are commonly used by retailers to send coupons and other offers to customers when they are near one of their stores.
According to the settlement with Healey, Copley Advertising used GPS coordinates and other location data generated by smartphones to identify people who entered an area around a health care facility.
Healey’s office did not specify where Copley obtained the data, but that kind of information is broadly available to advertisers, said Andy Sellars, director of Boston University’s Technology & Cyberlaw Clinic.
“Users, when they download smartphone apps, will often allow those apps to get their location information. They could get that information and then sell it,” Sellars said. “So it could be that [Copley] is partnering with apps that do this.”
In addition, data brokers that specialize in compiling information from apps and other sources can repackage the information and sell it to advertising providers, Sellars said.
But he and other legal experts who specialize in privacy issues were divided on the tactic used by Healey, saying the courts have not settled the free-speech and privacy questions raised by the settlement. They also called it a revealing glimpse at the kind of data companies can collect about people based on their use of the Internet, smartphones, and common apps, such as social media, coupon, or mapping services.
David Greene, civil liberties director with the Electronic Frontier Foundation, said the campaign targeting women in reproductive health clinics was “quite crass behavior.” But, he added, advertisers might win a court case on the issue.
“They have a First Amendment right, I think, to communicate with people,” Greene said.
Sellars said Healey’s use of state consumer protection statutes to obtain the settlement with Copley was also unusual because of the highly political context around abortion services.
“It should give people pause to see the use of consumer protection laws to regulate what’s clearly political speech,” he said.
But Kade Crockford of the ACLU of Massachusetts praised Healey for protecting the privacy of consumers seeking medical care from marketing efforts that exploit information about their personal behavior.
“That kind of thing might not bother people when it’s used in ways that seem mundane and harmless,” Crockford said. “It is predatory, in my opinion, to target those women.”
The fact that Copley’s campaigns were about abortion and the details of the messages were not the issue, Healey said.
She invoked a broadly written section of state law that protects consumers against unfair or deceptive trade practices by businesses, arguing in the settlement the ad program developed by Copley “intrudes upon a consumer’s private health or medical affairs” and uses that information “without his or her knowledge or consent.”
“They weren’t sending them ads for free gasoline or discounts at Macy’s,” Healey added. “They were sending them messages that related directly to their health and medical status which, by definition, meant that they were improperly accessing somebody’s private medical health data in a way that we feel is exploitive.”
Flynn was listed as a speaker at a January 2016 antiabortion convention sponsored by the Family Research Council, a conservative political group. His presentation for that conference, distributed through Flynn’s Twitter account, described the ability to reach women who might be considering abortions.
Planned Parenthood, one of the organizations specifically mentioned as a target location in Copley’s ads, cheered Healey’s action.
“Every person deserves access to high-quality, confidential care in a space that is safe, nonjudgmental, and free from harassment,” said Jennifer Childs-Roshak, chief executive of the Planned Parenthood League of Massachusetts.
Sellars said the Massachusetts settlement touched on some of the same privacy questions raised by a new measure, signed into law this week by President Trump, that allows Internet service providers to sell the browsing habits of their customers to advertisers.
Most consumers don’t know that an advertiser might be able to target them based on their visits to a doctor’s office, he said. But data brokers can collect a very detailed picture of a person’s behavior.
“By nature of using the Internet and using technology, we are shedding off a lot of information about ourselves. And there are companies that systematically slurp up that information wherever they can find it to build dossiers to target people,” he said.Curt Woodward can be reached at firstname.lastname@example.org. Follow him on Twitter @curtwoodward. Hiawatha Bray can be reached at email@example.com. Follow him on Twitter @GlobeTechLab.