WASHINGTON (AP) — Protecting the privacy of law-abiding citizens from the government is a pillar of Ted Cruz’s Republican presidential candidacy, but his campaign is testing the limits of siphoning personal data from supporters.

His “Cruz Crew” mobile app is designed to gather detailed information from its users’ phones — tracking their physical movements and mining the names and contact information for friends who might want nothing to do with his campaign.

That information and more is then fed into a vast database containing details about nearly every adult in the United States to build psychological profiles that target individual voters with uncanny accuracy.

Cruz’s sophisticated analytics operation was heralded as key to his victory in Iowa earlier this month — the first proof, his campaign said, that the system has the potential to power him to the nomination.

After finishing a distant third in New Hampshire, Cruz is looking to boost the turnout of likely supporters in South Carolina and in Southern states with primaries on March 1, where voters are more evangelical and conservative.

The son of mathematicians and data processing programmers, Cruz is keenly and personally interested in the work.

“Analytics gives the campaign a roadmap for everything we do,” said Chris Wilson, data and digital director. “He has an acute understanding of our work and continually pushes me on it.”

Data-mining to help candidates win elections has been increasing among both Republicans and Democrats. Mobile apps by other presidential campaigns also collect some information about users.

But The Associated Press found the Cruz campaign’s app — downloaded to more than 61,000 devices so far — goes furthest to glean personal data.

The Cruz app prompts supporters to register using their Facebook logins, giving the campaign access to personal information such as name, age range, gender, location and photograph, plus lists of friends and relatives. Those without a Facebook account must either provide an email address or phone number to use the app.

By contrast, the app offered by GOP candidate Ben Carson’s campaign asks supporters to surrender the same information as Cruz from their Facebook accounts, but also gives an option to use it without providing any personal information. Carson’s app separately asks users to let the campaign track their movements and asks them to voluntarily supply their birthdate and gender — including options for “male,” ”female” and “other.”

Ohio Gov. John Kasich’s campaign app doesn’t request personal information from supporters, but it repeatedly nags users to let the campaign track their movements until they answer yes.

Democratic Sen. Bernie Sanders’ app, “Field the Bern,” requires supporters to sign in using their Facebook account or an email address, and it also repeatedly asks to let the campaign track their movements until they answer yes.

The other 2016 presidential contenders, including Donald Trump and Hillary Clinton, appear not to have officially sanctioned campaign apps in Apple and Android stores.

The Cruz app separately urges users to let it download their phone contacts, giving the campaign a trove of phone numbers and personal email addresses. The campaign says that by using its app, “You hereby give your express consent to access your contact list,” but Wilson said the campaign will not do this to anyone who declines to allow it when the app requests permission.

Cruz’s app also transmits to the campaign each user’s physical location whenever the app is active, unless a user declines to allow it. The campaign said it does this “so that we can connect you to other Cruz Crew users based on your particular geographic location.”

The campaign tells users it can share all the personal information it collects with its consultants or other organizations, groups, causes, campaigns or political organizations with similar viewpoints or goals.

It also shares the material with analytics companies. Cruz’s campaign combines the information with data from a group called Cambridge Analytica, which has been involved in his efforts since fall 2014. A Cambridge investor, Robert Mercer, has given more money than anyone else to outside groups supporting Cruz.

Sanders’ campaign said it shares personal information from supporters with its consultants and vendors but not analytics companies.

Cambridge has a massive 10 terabyte database — enough to fill more than 2,100 DVDs — that contains as many as 5,000 biographical details about the 240 million Americans of voting age. Cambridge considers its methodology highly secretive, but it may include such details as household income, employment status, credit history, party affiliation, church membership and spending habits. Cambridge uses powerful computers and proprietary algorithms to predict Americans’ personality traits.

The Cruz campaign paid Cambridge $3.8 million in 2015, accounting for more than 8 percent of all its spending. Two outside groups supporting Cruz, including one directly funded by $11 million from Mercer, paid the firm $682,000 since December. Cambridge has five employees at Cruz headquarters in Houston and 70 others split between New York City and the Washington suburbs.

The power of Cruz’s data-driven systems was on display in Iowa.

The GOP candidates held similar positions on issues such as abortion and gun control. Cambridge helped differentiate Cruz by identifying automated red light cameras as an issue of importance to Iowa residents upset with government intrusion. Potential voters living near the red light cameras were sent direct messages saying Cruz was against their use.

“Everything in this campaign is data-driven. I’ve never seen anything like it,” said Jerry Sickles, a paid field representative in Hooksett, New Hampshire, who uses the Cruz Crew app. “We just know exactly who our voters are, and we will make sure they get out to vote.”

Cruz, the junior senator from Texas, has been outspoken about protecting Americans’ personal information from the government, including the National Security Agency. “Instead of a government that seizes your emails and your cellphones, imagine a federal government that protected the privacy rights of every American,” he said when announcing his campaign.

Cruz campaign officials say it’s different for the government versus a campaign to collect data. Sickle said Cruz is building on the use of big data pioneered by the successful Democratic campaigns of Barack Obama in 2008 and 2012.

“It’s not like we’re giving it to the NSA,” Sickle said.

A campaign spokeswoman, Alice Stewart, added: “Why wouldn’t we want to use every tool available to us to win?”

The scope of Cruz’s system is formidable. Cambridge’s database combines government and commercial data sets such as voter rolls and lists of people who liked certain Facebook posts, along with consumer data from grocery chains and other clients that can provide a voter’s preferred brand of toothpaste or whether he clips coupons. In Iowa, where identifying evangelical voters was key to Cruz’s victory strategy, Cambridge’s employees scoured the Internet for such useful information as church membership rolls.

Cambridge CEO Alexander Nix said the company categorizes every American into one of five basic personality types derived from academic research and up to 50,000 questionnaires conducted each month.

“We’ve quantified the personalities of every adult American,” Nix said. “We can reach out and target those different clusters with messages about the things they care about most, but that have been nuanced to resonate with their personality type.”

For example, a Cruz campaign worker about to knock on the door of a house would access information about the household’s members through the Cruz Crew app, receiving prepared scripts about what issues each person was likely to care about, modified to appeal to their personality.

Even within issues such as the right to bear arms, Nix said personality types will tailor the message. For voters who care about traditions or family, a message may resonate about guaranteeing the ability of a grandfather teaching shooting lessons. For someone identified as introverted, a better pitch might describe keeping guns for protection against crime.

Cambridge and the Cruz campaign stressed that anyone providing personal information through the app does so voluntarily. Data uses are outlined in legal disclosures available on the campaign’s website.

Cambridge said it operates behind firewalls on its computer servers to secure its data and follows all applicable U.S. laws. Cambridge runs its operations out of the U.S.; they would be illegal in Europe under stricter privacy laws there.

In the hours before the Iowa vote, the campaign pushed urgent messages through its app to users who had Iowa contacts listed in their phones. The app displayed pre-written text messages the supporters were encouraged to forward to their Iowa acquaintances, urging them to caucus for Cruz.

The chief technologist at the privacy advocacy group Center for Democracy and Technology, Joe Hall, said politicians are unlikely to strengthen privacy protections as their campaigns become more and more reliant on mining personal data to squeeze out votes.

“This is a form of political-voter surveillance,” Hall said. “If people understood that this amount of fine-grained, sensitive data was being used by political campaigns, they would likely feel betrayed.”

___

Follow Michael Biesecker on Twitter at https://twitter.com/mbieseck and Julie Bykowicz at http://twitter.com/bykowicz

Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.