Privacy-Preserving Analytics and Experimentation Questions
Doing measurement and data science without over-collecting or exposing individuals: privacy-preserving experiment design, aggregate and on-device measurement, and privacy-respecting attribution. Covers techniques for analytics and A/B testing that limit personal-data use and honor consent. Includes reconciling measurement quality with privacy constraints.
Privacy regulations require excluding certain users from aggregated reports. Describe how you would implement privacy-aware reporting for product metrics across Meta's apps. Address consent flags, differential privacy or aggregation thresholds, and how to communicate limitations to stakeholders.
Sample Answer
Situation: As a BI analyst responsible for product metrics across Meta apps, I must ensure reports exclude users per privacy regulations (GDPR/CCPA) while keeping metrics useful.
Approach / Implementation:
- Data model & consent flags: persist explicit consent/status flags at ingestion (consent_timestamp, consent_version, granular flags like analytics_opt_in). Join reports only to users with valid consent; mark historical data retention windows per regulation.
- Privacy enforcement layer: implement a centralized privacy middleware (SQL views / materialized tables) that applies exclusion logic before any BI tool hits data. All downstream ETL and Looker/Tableau models reference these sanitized tables.
- Aggregation protections:
- Thresholding / suppression: require minimum cohort size (e.g., k=10); suppress or return “<10” when below threshold.
- Differential privacy for high-sensitivity metrics: apply DP noise (Laplace/Gaussian) with defined epsilon per metric and a global privacy budget; add noise post-aggregation (not per-user) and track cumulative budget per report.
- Rounding and bucketing: round small counts, group rare categories to avoid re-identification.
- Access controls & auditing: RBAC for raw tables, immutable audit logs of queries and privacy decisions, automated tests to verify exclusions.
Communicating limitations:
- Dashboard metadata: show visible banners/tooltip explaining exclusions, thresholds, and whether DP was applied (include epsilon and expected noise magnitude).
- Provide data quality panel: cohort sizes, suppressed counts, and guidance on interpreting noisy values (confidence intervals).
- Stakeholder playbook: short doc and templates explaining when to use sanitized vs. restricted datasets, procedures to request access to raw data (legal review), and escalation for product decisions needing precise counts.
Result: This preserves regulatory compliance and user trust while keeping stakeholders informed about accuracy trade-offs and how to interpret metrics.
Design an analytics architecture that allows BI reporting while complying with GDPR/CCPA when using pseudonymized user identifiers. Address: separation of identity and analytics layers, data minimization, access controls, auditability for deletion or subject access requests, and how to handle historical aggregates needing deletion.
Sample Answer
Requirements & constraints:
- BI must use pseudonymized IDs (no direct identifiers in analytics layer).
- Support GDPR/CCPA: right-to-access, right-to-delete, data minimization, audit trail.
- Low-latency dashboards (Looker/Tableau) and scheduled reports.
High-level architecture:
- Identity Layer (secure service): stores PII and mapping (user_id -> pseudonym_id) in an encrypted, access-controlled store (vault/DB). Exposes APIs for lawful queries (auth, logging).
- Ingestion & ETL: Raw events include pseudonym_id only. PII never flows into analytics pipelines. ETL performs minimal enrichment (no PII), tags events with pseudonym_id.
- Analytics Warehouse: columnar store (BigQuery/Snowflake) holding pseudonymized event data and dimensional tables without PII. BI tools connect only to this layer.
- Access & Governance: role-based access (RBAC) and attribute-based controls (ABAC) on warehouse; BI extracts limited to aggregated views (no row-level personal profiling unless approved).
- Audit & Compliance: centralized audit logs for identity queries, deletion requests, and ETL jobs; immutable write-once logs (WORM) for auditability.
Data minimization & controls:
- Store only fields required for analytics; drop or hash unnecessary fields at ingestion.
- Use one-way hashes with per-environment salt for pseudonym_id to prevent cross-system re-identification.
- Implement data retention policies: partition-by-date and automated TTL to purge raw partitions.
Handling deletion / subject requests:
- Deletion request flow: verify identity → identity layer removes/flags mapping and records deletion event → emits deletion token/event to ETL/CDC pipeline.
- Analytics deletion strategies:
- Soft-delete + filter: mark pseudonym_id as deleted; any future queries or dashboards exclude flagged IDs via a global filter. Good for quick compliance but leaves historical aggregates.
- Recompute aggregates: maintain event-level data partitioned; on deletion, trigger recompute of affected aggregate materialized views for windows that included the user. Use incremental recompute jobs for affected partitions for scalability.
- Privacy-preserving aggregates: where recompute is infeasible, apply techniques:
- Differential privacy noise to aggregated metrics so single-user removal has negligible effect.
- Minimum group-size thresholds (suppress cells with < k users).
- Recommendation: Combine (1) + (2) for critical KPIs (sales, billing) and (3) for large, derived cohorts where full recompute is cost-prohibitive.
Auditability:
- Log every identity lookup, deletion, and recompute job with who/why/timestamp and checksum of resulting aggregates.
- Provide subject access: identity layer can use mapping to fetch pseudonymized records and produce an export from analytics data filtered to that pseudonym_id, with access logged.
- Maintain an immutable trail linking deletion request → ETL events → aggregate recompute jobs → final state (hashes/checksums) for regulators.
Operational considerations for a BI Analyst:
- Build BI views as parameterized, governed datasets that automatically respect global "exclude_deleted" filters.
- Document which dashboards require recompute on deletion vs. privacy-preserving approaches.
- Work with engineering to schedule nightly incremental recomputes for business-critical aggregates; surface delays and uncertainty in dashboards metadata.
- Add data quality/monitoring alerts for failed deletion propagation and aggregate drift.
Trade-offs:
- Full recompute ensures strongest compliance but costs time/compute for high-cardinality aggregates.
- Privacy-preserving methods reduce cost but may reduce accuracy and require stakeholder buy-in.
This design separates identity from analytics, minimizes PII in BI systems, enforces strict access controls, provides auditable deletion and access flows, and offers practical strategies for handling historical aggregates.
Spotify operates globally with varying privacy regulations. As a BI lead, design a policy and technical controls to enable analytics while complying with GDPR/CCPA. Cover data minimization, pseudonymization, retention schedules, access controls, auditing, and how to support lawful research and monetization use cases without exposing PII.
Sample Answer
Situation / goal: Enable Spotify’s global analytics while ensuring GDPR/CCPA compliance and protecting PII, supporting lawful research/monetization without exposing identities.
Policy (high-level):
- Purpose limitation: define approved analytics purposes (product, personalization metrics, monetization, research). Any new purpose requires DPIA.
- Data minimization: collect only fields necessary per purpose; prefer aggregated metrics over raw events.
- Lawfulness: map legal bases (consent, performance of contract, legitimate interest) by region; record basis per dataset.
- Retention: default retention windows per data type with automated deletion/archival; retention exceptions require documented justification and approval.
- Data subject rights: processes for access, portability, rectification, erasure; redaction and dataset reconstitution procedures.
- Governance: data owners, stewards, and a Privacy Review Board for new analytics projects.
Technical controls:
- Pseudonymization & hashing:
- Replace user identifiers (email, user_id) with salted one-way pseudonyms per purpose/environment. Use HMAC with per-tenant keys stored in HSM/KMS.
- Store true identifiers in a separate identity vault accessible only to a small IAM group for legal needs.
- Minimization at ingest:
- Ingest pipelines enforce schemas that drop disallowed PII and enforce field-level allowlists/denylists.
- Tokenize device identifiers; only pass pseudonymous IDs downstream.
- Aggregation & differential safety:
- Enforce minimum aggregation thresholds (k-anonymity thresholds, e.g., k≥10) for reports.
- For high-risk analytics, apply differential privacy mechanisms (noise calibrated to epsilon) before export.
- Access controls:
- RBAC + attribute-based access control (ABAC) tied to purpose and legal basis. Analysts request scoped access via ticketed workflows.
- Time-bound access tokens for adhoc queries; just-in-time elevation with manager approval.
- Environment separation:
- Production identity store isolated; analytics environments receive only pseudonymized/aggregated datasets.
- No PII in BI tools (Looker/Tableau) dashboards except approved internal admin views.
- Retention & deletion automation:
- Data lifecycle orchestration: automatic TTL expiration and purge, with immutable audit logs of deletions.
- Soft-delete + secure wipe for long-term archives; verify via cryptographic deletion proofs when possible.
- Auditing & monitoring:
- Full audit trail of dataset access, query logs, exports, and sharing actions; logs immutable and retained per policy.
- Automated anomaly detection for unusual access patterns and data exfiltration attempts.
- Supporting research & monetization:
- Research sandbox with stricter controls: researchers access synthetic or differentially-private datasets; access requests reviewed by Privacy Board.
- Monetization: only provide aggregated or pseudonymized cohorts; data-sharing contracts enforce purpose, prohibited reidentification, and breach obligations.
- Data Use Agreements and DPIAs before any third-party data monetization; contractual obligations mirrored in technical enforcement (token scoping, encrypted exports).
Operational practices:
- DPIA for new analytics pipelines, periodic privacy risk assessments.
- Key rotation, KMS/HSM for pseudonym keys, strict key access staging.
- Privacy-by-design reviews during BI dashboard requirements gathering.
- Training for BI analysts on safe query patterns and PII spotting.
- Regular audits (internal + external) and metrics: number of DPIAs, access violations, deletion SLA compliance.
Why this works:
- Minimization and pseudonymization reduce reidentification risk; separation and strict RBAC limit exposure; aggregation/differential privacy protect individuals even in published outputs; automated retention and auditing provide demonstrable compliance for regulators and internal governance, while sandboxes and contractual controls enable lawful research and monetization.
Design a measurement strategy to compute unique users and cross-device engagement metrics under GDPR constraints while minimizing PII storage. Describe approaches such as salted hashed identifiers, differential privacy, or aggregated bucketing, list trade-offs between accuracy and privacy, and explain how you would validate measurement accuracy.
Sample Answer
Requirements & constraints:
- Count unique users and measure cross-device engagement (sessions, conversions, retention) while minimizing PII retention and complying with GDPR (right-to-be-forgotten, purpose limitation, data minimization).
- Low latency for dashboards, tolerable approximation for aggregated metrics.
High-level approach:
-
Client-side pseudonymous IDs:
- Generate per-device ephemeral ID (device_id) stored in browser/app.
- If user consents to cross-device linking, create a salted-hash of a user identifier (email/phone) on client before sending. Salt is per-organization secret rotated periodically; hashing uses HMAC-SHA256.
- Server stores only hashed_id (no raw PII) and device_ids.
-
Cross-device linking:
- Use hashed_id to join device_ids to a pseudonymous user_id. Keep mapping in a minimal TTL store; persist aggregated user buckets only (see below).
- For users who decline linking, report device-level metrics only.
-
Privacy-preserving aggregation:
- Aggregate events into time-windowed buckets (day/week) and dimension buckets (country, channel).
- Add calibrated differential privacy noise to counts for low-volume buckets to protect re-identification. Use epsilon tuned for business needs.
- For unique counts, use HyperLogLog (HLL) on hashed_ids; apply bias correction and add DP noise to HLL estimates for small cardinalities.
-
Data minimization & GDPR ops:
- Store raw event logs for short TTL (e.g., 7 days) for debugging, then only aggregated HLL sketches and counters.
- Implement forget API: when subject requests deletion, remove hashed_id from join store and subtract from aggregates via recomputation from retained ephemeral data or mark as tombstone and recompute rollups.
Trade-offs (accuracy vs privacy):
- Salted hashed identifiers: high linkage accuracy for consenting users; risk if salt leaked. Mitigation: rotate salts, HSM storage.
- HLL + DP: scalable with low storage and good accuracy at large cardinalities; introduces error for small cohorts and additional DP noise reduces accuracy.
- Aggregated bucketing: reduces re-identification risk but loses granularity (fine timestamps, exact funnels).
Validation strategy:
- A/B validation with a parallel trusted pipeline (on a small consented cohort storing raw identifiers) to measure bias introduced by hashing/HLL/DP. Compare unique counts, retention curves, and conversion rates; calculate relative error by cohort size.
- Injection tests: generate synthetic users with known properties to verify aggregation and deletion (GDPR) pipelines.
- Monitoring: expose confidence intervals and expected error margins on dashboards; alert if divergence vs baseline exceeds thresholds.
Operational notes:
- Document epsilon choices and retention policies; surface consent flags in BI joins.
- Use secure key management (KMS/HSM) for salts; audit access.
- Communicate measurement limits to stakeholders (small-cohort metrics have higher uncertainty).
A compliance request requires that any aggregated result shown to end users must not expose groups smaller than k=5 individuals. As a BI analyst, propose SQL-level strategies to produce aggregates that comply: suppression of small groups, coarsening/binning to ensure minimum group size, adding noise or differential privacy approaches, and describe performance trade-offs and dashboard UX impacts.
Sample Answer
Approach: provide SQL patterns for (1) suppression, (2) coarsening/binning, (3) noise / DP-style aggregation plus practical notes on performance and dashboard UX trade-offs.
Suppression (hide groups < k):
WITH grp AS (
SELECT country, COUNT(*) AS n, SUM(amount) AS total
FROM sales
GROUP BY country
)
SELECT country,
CASE WHEN n >= 5 THEN total ELSE NULL END AS total_masked,
CASE WHEN n >= 5 THEN n ELSE NULL END AS n_masked
FROM grp;
- Simple, fast (single GROUP BY). UX: shows blanks/“<5” labels; users lose visibility into small segments.
Coarsening / binning (increase group sizes):
WITH b AS (
SELECT
CASE
WHEN age BETWEEN 18 AND 24 THEN '18-24'
WHEN age BETWEEN 25 AND 34 THEN '25-34'
ELSE '35+' END AS age_bucket,
COUNT(*) AS n, SUM(amount) AS total
FROM users JOIN sales USING(user_id)
GROUP BY 1
)
SELECT age_bucket, total, n
FROM b
WHERE n >= 5;
- Pre-aggregate or create materialized views for repeated use. UX: less granular but preserves insights; requires stakeholder alignment on bucket definitions.
Adding noise / DP-like approach:
-- Laplace noise example (conceptual; DB must support random functions)
WITH agg AS (
SELECT country, COUNT(*) AS n, SUM(amount) AS total FROM sales GROUP BY country
)
SELECT country,
n + CAST( ( -LN(RANDOM()) * sign - ) AS INT) AS n_noisy, -- pseudocode
total + (RANDOM() - 0.5) * sensitivity * scale AS total_noisy
FROM agg;
- Use DB or external library to add calibrated noise (or use a DP library). Performance: similar to normal aggregates but requires care to compute sensitivity and calibration. UX: provides plausible deniability; can confuse users — show confidence intervals and explainability.
Hybrid pattern (suppress small then add small noise to remaining):
- Suppress n<k, add noise to remaining to prevent re-identification via differencing.
Performance trade-offs:
- GROUP BY on high-cardinality columns is expensive; add indexes, pre-aggregate tables, or materialized views.
- DP libraries may require multiple passes or cryptographic operations; consider offline batch processing.
- Coarsening reduces cardinality and speeds queries.
Dashboard UX impacts & recommendations:
- Always display a clear legend/footnote explaining suppression, binning, or noise and what k=5 means.
- For suppressed cells show “<5” (non-numeric) instead of NULL to avoid misinterpretation.
- Provide drill-paths into approved aggregated views rather than raw data.
- Offer explainability panels: sample sizes, confidence intervals, and the method applied.
- Align with stakeholders to balance utility vs. privacy; default to stricter methods for executive/public reports.
Operational tips:
- Implement these in ETL or materialized aggregates to avoid per-dashboard computation.
- Log anonymization parameters and versions for audits.
- Test with synthetic data to measure analytic distortion before rollout.
Unlock Full Question Bank
Get access to all 12 Privacy-Preserving Analytics and Experimentation interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.