The law rarely keeps up with technological advances – except in Montana.

Legislators in that state recently passed a bill that requires the police to obtain a search warrant, based on probable cause, before they can use a cellphone carrier’s records to establish a suspect’s location.

That kind of “metadata” can be incredibly valuable, as law enforcement agencies discovered long before the rest of us. The cellphones we carry everywhere establish a clear log of our daily travels and can go a long way in telling the story of our lives.

In recognition of that fact, the Montana Legislature this spring passed a location information privacy bill, which requires a search warrant for location information recorded by an “electronic device.” There are exceptions to the warrant requirement, including when the cellphone is reported stolen or to respond to a cellphone user’s emergency call.

Steve Bullock, the governor of Montana, signed it into law on May 6. The American Civil Liberties Union, which tracks cellphone tracking laws across the country, called it the first such state legislation.

In so doing, Montana stole California’s thunder: that state’s Legislature had passed a warrant law for location tracking last year, but Gov. Jerry Brown vetoed it, saying that it did not “strike the right balance” between the needs of citizens and law enforcement.

Over a dozen other states have eyed similar measures just this year. In Maine, a location information privacy bill went to the governor’s desk last Wednesday. In Texas, a similar bill failed to muster enough votes in the Statehouse. The Massachusetts Legislature is scheduled to hold a hearing next Tuesday on a measure that would require search warrants for location records as well as content of cellphone communications.

Congress has been slow to act on the issue. Bills have been introduced in both the House of Representatives and the Senate, with little movement. The courts meanwhile have rendered mixed verdicts on how law enforcement can extract location history from telecommunications carriers.

Among the most remarkable is an armed robbery trial in Maryland, where the police obtained 221 days of cellphone location data for the suspects. The law enforcement authorities obtained a court order from a magistrate, but not a warrant.

The A.C.L.U., along with several other groups, filed an amicus brief in the case this week in the Fourth Circuit Court of Appeals, arguing that at a minimum, the police should obtain a warrant, based on probable cause, to gain access to cellphone location records.

The Supreme Court has yet to weigh in on the legal limits of location tracking using a cellphone, though it ruled in a landmark 2012 case that the police must obtain a search warrant before placing a GPS tracking device on a suspect’s vehicle.