Quick answer
k-anonymity is a property of a released table: each combination of identifying attributes (such as age band, postcode prefix and device) appears in at least k rows, so no one can be singled out to fewer than k records using those columns. It does not by itself make data anonymous.
Formula: k = size of the smallest group of rows that share the same quasi-identifier values
What is k-anonymity?
k-anonymity is a property of a released table: every combination of identifying attributes in it appears in at least k rows. If k is 5, anyone who knows a person's age band, postcode prefix and device type still finds at least five rows that match, and cannot tell from those columns which one belongs to that person.
The model comes from Latanya Sweeney and Pierangela Samarati's work in 1998 and was set out formally in Sweeney's 2002 paper. Its starting point was a concrete failure. Medical records released without names still carried ZIP code, birth date and sex, and Sweeney linked them to a purchased voter list to find the records of the then governor of Massachusetts. Her earlier analysis of 1990 US Census summary data estimated that 87% of the US population was likely unique on 5-digit ZIP code, gender and date of birth alone.
Three points keep the definition straight:
- k is the size of the smallest group, not the average. A table with a thousand large groups and one group of one has k = 1.
- It is a property of the table you hand out, judged against the columns you chose. Change the columns and k changes.
- It limits singling out. It does not, on its own, hide what the people in a group have in common.
Quasi-identifiers: which columns count
Before you can measure k you have to sort the columns. The usual split has three groups:
| Column type | Meaning | Website or support data examples | What to do before release |
|---|---|---|---|
| Direct identifier | Names a person by itself | Email, phone, account ID, full name | Remove |
| Quasi-identifier | Harmless alone, identifying in combination, and findable elsewhere | Postcode, age, device model, signup date, city, job title | Generalize or suppress until each combination reaches k |
| Sensitive attribute | The thing an attacker should not learn about a person | Ticket topic, plan cancellation reason, health or payment details | Check variety inside each group |
| Other | Neither of the above | Page load time bucket, report week | Keep if the question needs it |
Which column is a quasi-identifier depends on what an outsider can look up. Sweeney's paper is explicit that the data holder cannot know every value held elsewhere, so the judgment is a risk decision. A practical rule: if someone outside your team could plausibly know the value about a specific person (a colleague knows your city, age and phone model), treat it as a quasi-identifier.
k-anonymity example: before and after generalization
Sample data: an export of 12 support conversations that a team wants to share with an outside consultant. Names and emails are already removed. Age, ZIP code and device are the quasi-identifiers; the conversation topic is the sensitive attribute.
| Row | Age | ZIP | Device | Topic |
|---|---|---|---|---|
| 1 | 23 | 02138 | mobile | Payment hardship |
| 2 | 27 | 02139 | mobile | Login |
| 3 | 29 | 02141 | mobile | Delivery |
| 4 | 24 | 02142 | mobile | Login |
| 5 | 31 | 02138 | desktop | Payment hardship |
| 6 | 35 | 02139 | desktop | Payment hardship |
| 7 | 38 | 02141 | desktop | Payment hardship |
| 8 | 33 | 02139 | desktop | Payment hardship |
| 9 | 44 | 02446 | mobile | Delivery |
| 10 | 47 | 02445 | desktop | Login |
| 11 | 52 | 02446 | mobile | Refund |
| 12 | 58 | 02447 | desktop | Delivery |
All 12 combinations of age, ZIP and device are different, so k = 1. The consultant who knows that a particular 35-year-old on a desktop in 02139 wrote in can find row 6.
Two techniques raise k. Generalization replaces a precise value with a broader one (age 35 becomes 30–39, ZIP 02139 becomes 021). Suppression** removes a value or a whole row (device becomes \*). Applying both:
| Rows | Age band | ZIP prefix | Device | Group size | Topics in the group |
|---|---|---|---|---|---|
| 1–4 | 20–29 | 021** | \* | 4 | Login ×2, Payment hardship, Delivery |
| 5–8 | 30–39 | 021** | \* | 4 | Payment hardship ×4 |
| 9–12 | 40–59 | 024** | \* | 4 | Delivery ×2, Login, Refund |
The table is now 4-anonymous. Someone who knows a person is in it, and knows their age, ZIP and device, can narrow them down to four rows at best: a one-in-four chance of picking the right row. The price is detail. Twelve distinct ages became three bands, seven ZIP codes became two prefixes, and the device column is gone, so the consultant can no longer ask whether mobile users report different problems.
The homogeneity attack and l-diversity
Look at rows 5–8 again. All four have the same topic. The consultant does not need to know which row is the 35-year-old: whichever it is, the answer is "payment hardship". This is the homogeneity attack that Machanavajjhala and colleagues described in their l-diversity paper. k-anonymity was satisfied and the sensitive fact still leaked.
l-diversity adds a second condition: each group must contain at least l well-represented values of the sensitive attribute. In the simplest "distinct" reading, count the different values per group. The table above has groups with 3, 1 and 3 distinct topics, so it is only 1-diverse.
One fix is to widen the age band. Merge the first two groups into ages 20–39:
| Group | Size | Distinct topics | Most common topic | Share |
|---|---|---|---|---|
| 20–39, 021** | 8 | 3 | Payment hardship (5 rows) | 62.5% |
| 40–59, 024** | 4 | 3 | Delivery (2 rows) | 50.0% |
The table is still 4-anonymous (the smaller group has 4 rows) and now 3-diverse. It is not risk-free: across all 12 rows, 5 are payment hardship (41.7%), but for someone in the first group the observer's estimate rises to 62.5%. Counting distinct values does not stop that kind of probabilistic inference. The EU Article 29 Working Party made this point about l-diversity, and described t-closeness as a refinement that asks each group's distribution of sensitive values to resemble the distribution in the whole table.
What else k-anonymity does not stop
| Problem | What happens | Check before release |
|---|---|---|
| Background knowledge | The observer rules out values: if they know the person never orders physical goods, "Delivery" drops out | Assume recipients know something about some individuals |
| Missing quasi-identifier | A column you left in, such as exact signup time, splits groups back to size 1 | List every column and ask who could know it elsewhere |
| Complementary release | Two exports of the same people, generalized differently, are joined on a shared column | Base later releases on the earlier one, or treat all released columns as quasi-identifiers |
| Updates over time | Next month's export differs by a few rows, and the difference identifies them | Compare releases, not only each file on its own |
| Row order | Two files sorted the same way can be matched line by line | Shuffle rows in every file |
| Small k | With k = 2, a recipient who knows one member has a one-in-two guess about the other | Raise k as the sensitivity rises |
Sweeney's paper names the row order, complementary release and temporal cases as attacks on releases that otherwise satisfy the definition. NIST SP 800-188 states the general limit: k-anonymity and its refinements are not compositional, meaning they do not measure the combined privacy loss of several releases.
Minimum thresholds in analytics reports
The same idea shows up in aggregate reports as a minimum cell size: do not show a number if it counts fewer than a set number of people. A published rule is the US Centers for Medicare & Medicaid Services policy for its research data: no cell with a value from 1 to 10 may be reported, and no other figures may allow such a value to be derived. That policy applies to those health datasets, not to web analytics, but the second half is the part teams forget.
Sample data: visitors who started a chat, by sales region and device, with a rule of hiding cells from 1 to 10.
| Region | Mobile | Desktop | Row total |
|---|---|---|---|
| North | 140 | 6 | 146 |
| South | 95 | 88 | 183 |
| Column total | 235 | 94 | 329 |
Hiding only the 6 achieves nothing: 146 − 140 = 6. Hiding both North cells does not help either, because 235 − 95 recovers 140. With both sets of totals shown, a single small cell in a two-by-two table forces you to hide all four inner cells, or to drop a dimension and publish only the region totals (146 and 183). Decide the breakdown before looking at the numbers, and check totals, percentages and date ranges that can be subtracted from one another.
A threshold is not the same as k-anonymity. It protects the cells of one report. It does not stop someone from running a second report with a slightly different filter and subtracting the two.
k-anonymity vs anonymization and pseudonymization
These three answer different questions. Anonymization is the outcome: people can no longer be identified by reasonable means. Pseudonymization replaces identifiers with codes that can still be linked with extra information. k-anonymity is one measurable technique on the way.
| k-anonymity | Pseudonymization | Anonymization | |
|---|---|---|---|
| What it is | A property of a table: groups of at least k | Swapping identifiers for tokens or keyed hashes | A result: identification no longer reasonably likely |
| Handles quasi-identifiers | Yes, by generalizing or suppressing | No; they usually stay as they are | Must, one way or another |
| Rows for one person can be linked | Within a group, only to 1 in k | Yes, through the token | Should not be possible |
| Legal status under GDPR | Depends on the remaining risk | Still personal data (Recital 26) | Outside the GDPR |
The Article 29 Working Party's opinion on anonymisation techniques is direct about k-anonymity: it can prevent singling out, but it does not prevent inference. Reaching a chosen k therefore does not by itself make a dataset anonymous. Whether a particular release is anonymous is a legal assessment, and this page is not legal advice. For other techniques, including ones that add random noise, see privacy-enhancing technologies.
Checking k before you share analytics data
TapCub does not calculate k or l for you, so the measurement happens on the file you export. The 12-row example maps onto four steps:
- Classify properties. In All-platform analytics › Data › Property dictionary, run Scan now and set each property's sensitivity to direct identifier, indirect identifier or non-personal. The indirect identifiers are your candidate quasi-identifiers.
- Cut detail at intake where you never need it. Governance rules on the same page can block a key so it is never stored, or set a whitelist so that other values are stored as
__other. These rules shape what is collected from then on; they do not rewrite old rows. - Export and count. In All-platform analytics › Data › Data export (Pro or above, Analyst role or above), create an events or persons export. In a script or spreadsheet, group by your quasi-identifier columns and take the smallest group count. That number is k. Then count distinct sensitive values per group.
- Share less than a file when you can. If the recipient needs trends, not rows, use a read-only link from Configuration › Settings › Public sharing, with only the modules they need and a password. Visitor lists and sessions cannot be shared this way.
If a group is still too small, generalize further or leave the column out, then count again. Data you did not collect needs no k at all, which is the argument for limiting personal fields from the start.
Sources
- Latanya Sweeney, k-anonymity: a model for protecting privacy, International Journal on Uncertainty, Fuzziness and Knowledge-Based Systems 10(5), 2002.
- Ashwin Machanavajjhala, Daniel Kifer, Johannes Gehrke and Muthuramakrishnan Venkitasubramaniam, ℓ-Diversity: Privacy Beyond k-Anonymity, author copy.
- Article 29 Data Protection Working Party, Opinion 05/2014 on Anonymisation Techniques, WP216, section 3.2.
- NIST, SP 800-188: De-Identifying Government Datasets, September 2023.
- ResDAC, CMS Cell Size Suppression Policy, version dated 26 January 2024. Checked 3 December 2026.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Solutions Engineer
Covers SDKs, API integrations, and data implementation, with an emphasis on validation, system interoperability, and troubleshooting.