Urban Outfitters was hit with a lawsuit charging that the trendy clothing retailer tricked customers into providing their ZIP codes by leading them to believe the information was necessary to process credit-card transactions, when the company really just wanted the information so it could mail them ads.

The lawsuit, filed in Washington, D.C., says customers started getting marketing materials from the company even though they’d never asked to be placed on a mailing list or given their full addresses. “Once the customer provides his/her ZIP code, the retailers have all the information they need to secretly obtain customers’ home/business address,” the suit says.

The suit sheds light on common but little understood data-collection practices by merchants. Most of us have, at some point, been asked for our address, ZIP code, phone number or e-mail address while buying something and wondered what the deal was. Here’s what you need to know.

Why do stores want the information? To try to sell you stuff, for the most part. But in some cases, retailers want to know where their customers are coming from so they can figure out the best place to open a new store. “There are others that perform analytics on the information, which is what’s alleged in a lot of these cases,” says Aaron Simpson, a partner in the privacy and cybersecurity team at the law firm of Hunton & Williams LLP.

“It’s a question of transparency,” plaintiffs’ lawyer Scott Perry told Buzzfeed. Some stores are up-front about it and will ask you if you’d like to give them your information so you can get flyers or coupons. The problem comes when retailers don’t make that clear to shoppers.

They don’t need your whole address to find you, either, thanks to the growing sophistication of big data. A Forbesarticle last month highlighted some of these companies’ marketing claims. One says, “Users simply capture name from the credit-card swipe and request a customer’s ZIP code during the transaction,” which lets stores “identify customers easily with accuracy rates close to 100%” and send them “dynamic, personalized marketing.”

There’s also the more remote but more troubling possibility that stores collect this data in order to either sell it to a data warehouser, or buy additional data from one of those companies to create a more detailed profile of who you are, says Evan Hendricks, publisher of Privacy Times. “They want it because they want to start building a profile,” he says. “I think it’s true sometimes they just want to send you a promotional flyer, which isn’t a burning privacy issue … But the trouble is, once they get your information, there’s very few restrictions on what they do with it.”

Do you have to give it to them? Generally, no. But like many other consumer-privacy issues, laws pertaining to it are made at the state level, creating what Simpson calls a “patchwork.” In other words: it’s a mess.

Elsewhere, a state might be running afoul of their merchant agreement with the card network, but they’re not breaking the law. For instance, MasterCard says, “A merchant cannot refuse to complete an in-store MasterCard transaction if the cardholder declines to provide this information to the checkout clerk.”

American Express lets stores call the shots, though. The company says, “It is the merchant’s discretion whether to process an American Express transaction if the cardmember refuses to provide his or her ZIP code.”

Are there any exceptions? If you swipe a card at a gas pump, you might get a prompt asking you for your ZIP code. This kind of transaction is generally exempt from laws about personal information, as are purchases that require delivery or installation, since the company needs to know where to send the package or technician.

When it comes to gas purchases, National Association of Convenience Stores spokesman Jeff Lenard says the ZIP code is a security measure. “Oftentimes, thieves test cards to see if they are still live at places where they don’t have to engage in a face-to-face transaction, such as at the gas pump,” he says. “Someone with a stolen card would be less likely to correctly enter the ZIP.”