THE VERY idea of the government amassing location data about millions of citizens is anathema to America’s strong sensibility for civil liberties — except, perhaps, if America is in the throes of an epidemic and the data is being amassed to help stop the disease’s spread.

The Wall Street Journal reported that officials across the country, from the federal Centers for Disease Control and Prevention to local leaders, are collecting analysis from the mobile advertising industry to track people’s movements. The goal is to build a portal full of information in as many as 500 cities harnessing the insight the companies have into our day-to-day lives — not to sell us stuff but to protect the public. But if this is necessary for our protection, there are nonetheless measures that could limit the cost and the risk.

Any privacy-infringing policies put in place mid-pandemic should be essential to quelling the crisis and genuinely effective. Health officials say that anonymized and aggregated data could aid in understanding the virus’s spread and the degree to which local populations are adhering to social distancing directives. Google has shown just how much of this information a single private company can compile with a cache covering 131 countries, down to the county level in the United States, that is as alarming as it is impressive.

Tracking movements to fulfill the third prong of the World Health Organization’s “test, treat and trace” framework may prove crucial in returning someday to normal life. But doing it right is tricky. For one thing, the United States still doesn’t have the capacity to test and treat. Telling an individual they’ve crossed paths with someone infected is less useful when there is little they can do about it — especially when the virus is so widespread and data so insufficiently precise that entire communities could receive alerts. When data-reliant contact tracing does occur, it should happen in the least invasive manner possible. Singapore’s system for transmitting Bluetooth signals between devices, for instance, relies on people’s proximity to each other rather than their whereabouts.

The aim is to preserve the most privacy and save the most lives all at once, and that demands honesty with the public about what’s being collected, who’s accessing it and how it’s being used. The government should mandate that transparency as well as the eventual deletion of data. It’s not encouraging that officials so far have shared very little with the public about their efforts , or that the surveillance industry appears to be playing a more prominent role in formulating national strategy than privacy experts.

Privacy amid a pandemic may look different from privacy at any other time. Yet without any bulwark against overreach, there’s a risk of eroding national norms around data protection in a way that will last long after this crisis is over. Openess and respect for privacy also will encourage public cooperation, which will continue to be essential as the crisis unfolds.

Read more: