Greta.sh

Implementation worksheet · 6 min read

How to Test Analytics Events Without Sending Customer Data

Use a separate analytics project per environment, keyed by an environment variable, and never let a non-production environment hold a production write key. That single change prevents the usual accident. Then pick a testing method by what you are checking: a local debug sink for whether events fire at all, a staging analytics project for end-to-end checks with synthetic users, contract assertions in your test suite for whether properties match the spec, and the vendor's own debug view for verifying delivery. Where a test must run against production, use a synthetic account you own and can delete, and exclude it from every report by a property rather than by memory.

Analytics testing gets done against whatever environment is easiest, which is usually production with a real login. It works, and it means a vendor receives events attached to a real customer from a session that was not a real use of the product — which pollutes the numbers and sends personal data somewhere nobody signed off. Both problems are avoidable with configuration that takes an hour.

Put it into practice

1. Separate the write keys by environment, in configuration

One project per environment, the key read from an environment variable, and the non-production key with no access to production data. If someone can run staging with the production key by exporting one variable, that will eventually happen during an incident when everyone is tired.

2. Add a local sink for the fastest loop

In development, point the analytics client at something that logs to a console or a local file rather than the network. Most vendor SDKs support this or can be wrapped. It makes 'did the event fire, with what' a one-second question, and it sends nothing anywhere.

3. Assert the contract in your test suite

A test that walks the signup flow and asserts the event name, the required properties and their types. This is where contract violations get caught cheaply — before a deploy rather than after a month of a malformed property quietly degrading a chart.

4. Use synthetic users for end-to-end checks

Named so they are obviously synthetic, carrying an is_test property, created and destroyed by the test. The property is what lets you exclude them from reports reliably; a naming convention alone fails the moment someone builds a report without knowing the convention.

5. Never send real personal data to a test project

Test payloads should use generated names and addresses, not a copy of a production record. Copying production data into a staging analytics project is the same disclosure as the accident this guide prevents, just with extra steps.

6. Check what the vendor actually received

Most platforms have a live debug view. Confirm delivery there rather than assuming your call succeeded. A silently dropped event and a correctly sent one look identical from inside your application — which is why 'we send the event' and 'the event arrives' are separate claims.

Testing method by question

Copy this structure into your review document and record your observed result for each row.

Testing method by question
QuestionMethodSends data to vendorSet up
Did the event fire at all?local debug sinkno
Do the properties match the contract?test-suite assertionsno
Does the full flow work end to end?staging project + synthetic usertest project only
Did the vendor receive it?vendor debug viewtest project only
Does it work in production?synthetic account, is_test propertyyes — your own account
Are test users excluded from reports?filter on is_test, not on namen/a

A failure worth checking

The production write key in a staging environment variable. Every staging session — QA clicking through flows, an automated test running hourly, a developer reproducing a bug — arrives in production analytics as real usage. Activation rates look better than they are, because test sessions complete flows that real users abandon. It is often discovered months later by someone who notices that a cohort of users signed up and activated within four seconds, and by then every historical comparison is contaminated.

Common questions

Is it ever acceptable to test in production?

Yes, with a synthetic account you own, carrying a property that excludes it from reports. What is not acceptable is testing with a real customer's account, which sends their behaviour to a vendor for a session that was not theirs.

How do I exclude test users from reports reliably?

Filter on an explicit property, set at creation and never inferred. Email-domain and naming conventions both fail the first time someone builds a report without knowing the convention, and nothing tells them it failed.

Basis and scope

This is a proposed implementation method using illustrative examples, not a measured benchmark or a customer case study. Prepared with AI assistance. Validate product-specific behavior against current documentation and your own test environment.

Continue with Greta.sh

Explore Greta →