Start by clarifying goals and constraints: we need a canonical user ID for analytics (de-duplication, cross-device funnels, lifetime value) while PII (email, SSN, raw IP) is restricted or cannot be stored.
Strategies
- Deterministic hashing
- Approach: Hash stable identifiers (email, phone, device_id) with a salted, keyed HMAC on ingestion server-side. Store only the HMAC outputs as user keys.
- Example attrs: normalized email, E.164 phone, hashed customer_id, merchant_account_id.
- Pros: High precision (exact matches), reproducible, simple joins.
- Cons: Misses non-exact matches (low recall) if data differs; key management critical.
- Probabilistic matching
- Approach: Compute similarity scores between records using non-PII signals (aggregated device signals, behavioral fingerprints, user-agent + geo/time windows) or fuzzy matching on hashed tokens (Bloom filters, private set intersection variants).
- Example attrs: hashed name tokens, zip+first_letter_of_lastname, hashed device fingerprint, login timestamp distributions.
- Pros: Higher recall—finds likely matches when deterministic fails.
- Cons: Lower precision, risk of false merges; requires threshold tuning and auditing.
- Identity graphs
- Approach: Build a graph of hashed identifiers and edges (deterministic links from login, transactional links, probabilistic edges with weights). Use graph algorithms to compute canonical cluster IDs (connected components, weighted clustering).
- Example: Node types: HMAC(email), HMAC(phone), device_id_hash, cookie_hash. Edges: login_event (strong), same_payment_method (medium), co-activity within 24h (weak).
- Pros: Rich lineage, explainability of merges; supports incremental updates.
- Cons: Complexity, compute cost, privacy risks from edge semantics.
- Server-side stitching
- Approach: Perform all identity resolution in a secure backend environment (no raw PII persisted). Expose only opaque canonical IDs and aggregated metrics to BI layer.
- Implementation: Ingest events into secure enclave, run HMAC, matching, and graph algorithms; emit canonical_id + privacy-safe attributes (cohort flags, segments).
- Pros: Minimizes PII exposure, centralizes key mgmt.
- Cons: Requires secure infra, audit trails, and compute.
Trade-offs: precision vs recall vs privacy
- Deterministic = high precision, low recall; probabilistic increases recall at expense of precision and higher re-identification risk.
- Aggressive stitching (low thresholds) improves funnel completeness but risks incorrect merges that bias metrics (overstated retention, misattributed revenue).
- Conservative strategies protect metric accuracy but under-count users.
Concrete attribute list (privacy-safe):
- HMAC(email_norm), HMAC(phone_norm), customer_id_hash (first-party), device_id_hash, cookie_hash, first_seen_date, geo at coarse granularity (country, state), hashed IP truncated + salt, hashed billing_token, aggregated behavioral vectors (p90 session_length, top 3 event types).
Legal & privacy considerations
- Minimize collection; apply data minimization and purpose limitation.
- Use keyed HMAC with rotating keys; store keys in KMS with strict access controls and logs.
- Prefer irreversible hashing over reversible encryption; avoid storing raw PII.
- Assess re-identification risk and perform DPIAs where required (GDPR). If using probabilistic linking, document merging logic and allow for opt-out/erasure workflows.
- Maintain retention policies, anonymize/aggregate before exporting to BI; surface only cohort-level or pseudonymized canonical IDs.
- In jurisdictions like GDPR/CCPA, ensure lawful basis (consent/legitimate interest), provide transparency, and honor data subject requests.
Operational best practices for BI
- Track merge provenance so analysts can exclude uncertain merges.
- Expose confidence scores and a “merged_by” reason in metadata; allow dashboards to filter by high-confidence canonical_ids.
- Regularly validate matching algorithms against labeled samples; monitor metrics for sudden shifts that signal erroneous stitching.
- Document assumptions in dashboards (e.g., “user counts reflect canonical IDs with ≥0.9 confidence”) to avoid misinterpretation.