How would you like it if the bookstore you happened to visit kept track of every book you look at before you make your decision on what to buy?

And after the purchase, would it be OK with you if the bookstore recorded how often you read the book, how long you view each page and even any notes you might write in the book’s margins?

Well, all those things are happening now with digital books. Many bookstores already collect information about readers and their purchases. But digital book services can collect even more detailed information that often is bundled in a database and sold to marketers or acquired by governments.

Are you reading an e-book about an illness you might have or religion or fringe politics? Someone might be looking over your shoulder.

New York’s and other states’ book privacy laws were written for libraries and did not anticipate online services that can collect vast amounts of information about reading habits. Digital book services without reader privacy protections have created a gold mine of information that can be used against readers without their knowledge and without proper due process.

Digital books now outsell paperbacks on Amazon.com, and more than 18 million e-readers, like Amazon’s Kindle or Barnes & Noble’s Nook, are expected to be sold in 2012.

A bill in the state Assembly would offer some privacy protection. The Reader Privacy Act, similar to legislation in California, would prevent digital book service providers from disclosing to any government entity personal information of a person who buys digital books. Nor would providers be compelled to disclose such information to anyone except under court order.

A digital book provider that knowingly violates these restrictions would face a $500 fine for each instance.

E-book providers, like Amazon or Google, would have to display prominent links on their Web pages that jump to their privacy policies regarding information collected and under what circumstances it could be given out. The policies must be written in clear and easily understandable language.

All consumers who want to buy an e-book would be required to check a box on Web page stating: I understand that by agreeing to this I am giving up certain privacy rights.

That’s a major flaw in the bill. The only folks who would be able to buy digital books in New York would be those who sacrifice their rights. That’s too high a price to pay for a book.

Still, with some retooling, the bill deserves support.

There’s a pressing need for New York — indeed, the nation — to keep up with technological developments so hard-won rights are not cast aside.