ANA-17Required EU law
Name the lawful basis for every experiment
Record the GDPR lawful basis for each experiment before it starts, and ask for consent before storing an experiment ID on the device. Screen tests that change prices, credit, health or content for children for a data protection impact assessment.
Region
European Union (EU). The duty comes from the law there. The rule applies only when the project serves people there, and its Applies when also holds.
How to do it
Assignment and exposure logs tie a variant to a person, so an experiment processes personal data. Most product tests rely on legitimate interest, which needs a written balancing test, as Weigh every legitimate interest in writing describes. Storing or reading an assignment ID in a cookie or local storage also falls under ePrivacy Article 5(3). Without a yes, assign signed-in users on the server by account ID, and show signed-out visitors the control. Tests with larger effects on people go through Screen every new feature for a DPIA. List the experiment store in the data map.
Examples
JavaScript example
export function variantForVisitor(experiment, { accountId, consent }) {
if (accountId) return variantFor(experiment.name, accountId);
if (!consent.analytics) return 'control';
return variantFor(experiment.name, consent.analyticsId);
}
Python example
def variant_for_visitor(experiment, account_id: str | None, consent) -> str:
if account_id:
return variant_for(experiment.name, account_id)
if not consent.analytics:
return "control"
return variant_for(experiment.name, consent.analytics_id)
How to check
Every experiment in the registry has a lawful basis and, for legitimate interest, a link to its balancing test. A browser test with a fresh profile and no consent finds no experiment ID in cookies or storage.
Sources
Related rules
- ANA-11 Write the experiment plan before it starts in Product analytics and experiments
- CMP-12 Weigh every legitimate interest in writing in Compliance and governance
- CMP-10 Screen every new feature for a DPIA in Compliance and governance
- CMP-7 Map every store that holds personal data in Compliance and governance
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/analytics/experiments/experiment-lawful-basis">Agent Wranglers product analytics and experiments playbook</a>. In code you write, add a comment next to it with the same link.