Controlling data storage

This guide covers the various features available after data reaches PostHog Cloud servers to help you achieve your privacy goals. If you have data that cannot reach a third-party server like PostHog, please omit them during data collection.

This guide covers the following features:

FeatureDescription
Data storage locationControl where your data is physically stored for GDPR compliance
Processing data before storageRedact or filter data before it's stored in PostHog
Data retentionHow long PostHog keeps each type of data
Data deletionTools to help comply with data deletion requests
Data access controlManage who can access what data in PostHog

Data storage location

If you require GDPR compliance, there are specific guidelines on the location of data storage if you collect personal data. If you require robust GDPR compliance, we recommend using PostHog Cloud EU – a managed version of PostHog that's hosted on servers based in Frankfurt.

Processing data before storage

PostHog supports realtime transformations of data before it's stored in PostHog. These transformations are applied to all events captured in realtime, so you can use them to:

When in doubt, you can always create your own custom transformation. Custom transformations use the Hog language to transform data.

Discarding IP addresses at project level

You can configure your project to discard client IP addresses from stored events. Navigate to Settings > Project > IP data capture configuration and enable the Discard client IP data toggle.

When this setting is enabled:

  • Client IP addresses are not stored with your events
  • Transformations like GeoIP enrichment and bot detection can still use the IP before it is discarded

This allows you to enrich your events with location data or filter out bot traffic while ensuring raw IP addresses are not retained in your data.

Note: This does not apply when Cookieless server hash mode is enabled. In cookieless mode, the IP is stripped before transformations run, so GeoIP enrichment and bot detection won't enrich your events.

See all default event properties collected

NameKeyExample value
Timestamp$timestamp2024-05-29T17:32:07.202Z
OS$osMac OS X
OS Version$os_version10.15.7
Browser$browserChrome
Browser Version$browser_version125
Device Type$device_typeDesktop
Current URL$current_urlhttps://example.com/page
Host$hostexample.com
Path Name$pathname/page
Screen Height$screen_height1080
Screen Width$screen_width1920
Viewport Height$viewport_height950
Viewport Width$viewport_width1903
Library$libweb
Library Version$lib_version1.31.0
Search Engine$search_enginegoogle
Referrer URL$referrerhttps://google.com
Referring Domain$referring_domainwww.google.com
Active Feature Flags$active_feature_flags['beta_feature']
Event Type$event_typeclick
UTM Source$utm_sourcenewsletter
UTM Medium$utm_mediumemail
UTM Campaign$utm_campaignproduct_launch
UTM Term$utm_termnew+product
UTM Content$utm_contentlogolink
Google Click ID$gclidTeSter-123
Google Ads Source$gad_sourcegoogle_ads
Google Search Ads 360 Click$gclsrcdsa
Google DoubleClick Click ID$dclidtestDclid123
Google Web-to-app Measure$wbraidtestWbraid123
Google App-to-web Measure$gbraidtestGbraid123
Facebook Click ID$fbclidtestFbclid123
Microsoft Click ID$msclkidtestMsclkid123
Twitter Click ID$twclidtestTwclid123
LinkedIn Ad Tracking ID$la_fat_idtestLaFatId123
Mailchimp Campaign ID$mc_cidtestMcCid123
Instagram Share Id$igshidtestIgshid123
TikTok Click ID$ttclidtestTtclid123
Plugins Succeeded$plugins_succeeded['GeoIP (56578)']
Plugins Failed$plugins_failed['plugin3']
Plugins Deferred$plugins_deferred['plugin4']
IP Address$ip192.168.1.1

Data retention

How long PostHog keeps your data depends on the type of data. This table covers the main types. Follow the links for details and settings.

DataHow long PostHog keeps it
EventsDepends on your plan and retention setting. See events retention.
Person profiles and propertiesUntil you delete them. Events retention doesn't apply to them.
Session recordingsDepends on your plan. See recording retention.
AI eventsThe large properties of $ai_ events, like prompts and outputs, are deleted after 30 days. See AI event data retention.
Logs14 days by default. See logs retention.
Heatmaps90 days.
Data pipeline logs90 days for the logs of destinations and transformations.
File download exportsOne week. See file download exports.
Query log3 months. See query log retention.
PostHog AI chatsUntil the user, project, or organization they belong to is deleted. Deleting a chat hides it, but PostHog keeps it until then.
Support ticketsWhile your account is active. Deleted tickets are permanently removed 14 days after deletion.
BackupsAbout two weeks for event data and about 12 months for app data. See backups.

Backups

PostHog keeps backups so it can restore service after an incident. Backups expire on a fixed schedule:

  • Event data: about two weeks
  • App data stored in Postgres, such as your account, project settings, and support tickets: about 12 months

Retention periods and deletion requests don't apply to data inside backups. Data you delete stays in existing backups until those backups expire.

Data deletion

You can remove unwanted data from PostHog by deleting groups and persons.

What to deleteWhere to deleteAdditional details
Your accountAccount settingsAccount is deleted immediately; all stored data about you is cleared within 30 days, apart from copies in backups. See deleting your account.
ProjectsProject settingsAll data under the project (including events) are automatically removed
OrganizationsOrganization settingsDeletion is processed in the background and typically takes a couple of minutes. You'll see a blocking screen while it completes. All data under the organization's projects (including events) are automatically removed.
PersonsIn the persons tab, by APIWhen a person is deleted, all events and session recordings for that person can be deleted. Some data isn't covered, see what deleting a person doesn't remove

Organization admins can also set a custom events retention window. PostHog deletes events older than the window at the next monthly cleanup, not right away. To answer a right to be forgotten request, delete the person instead.

Right to be forgotten

Avoid reusing deleted distinct IDs

User deletion requests are not immediate, but processed asynchronously. We recommend that you avoid reusing a deleted distinct_id value for a new user, as it may lead to unexpected results while the deletion is being processed. Once the deletion process is fully processed, PostHog does not retain any data associated with the deleted distinct_id.

If you must reuse the distinct_id, you can do so using the Reset deleted person tool, available from the dropdown at the top-right of the persons page. This tool enables you to reset a deleted distinct_id so that future events associated with it create a new person profile.

If you instead want to split a person with multiple IDs (e.g. to isolate bad data tied to a specific distinct_id), use the Split IDs button on their person profile.

Persons and events can be deleted using our API endpoints. This action requires a personal API key.

To query all persons in your project, use the GET Persons API endpoint. You can filter for specific subsets of persons using the query parameters. For example, you can get a specific person by filtering by email:

export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
https://us.posthog.com/api/projects/:project_id/persons?email={EMAIL}

To delete persons and their events, use the DELETE Persons API endpoint with the person's UUID (returned as id in the persons API response). To delete the person's corresponding events, add the delete_events=true parameter. To also delete their session recordings, add delete_recordings=true:

curl -X DELETE "https://app.posthog.com/api/projects/<project_id>/persons/<person_uuid>?delete_events=true&delete_recordings=true" \
-H "Authorization: Bearer <personal_api_key>"

This request deletes all events of the person(s) captured before the deletion request. When delete_recordings=true is set, all session recordings for the person are permanently destroyed using crypto-shredding, which irreversibly deletes the encryption keys making recordings unreadable. This process cannot be undone.

Bulk delete response

The bulk_delete endpoint returns a 202 once the request is accepted. Person records are not removed during the request. They are queued and deleted in the background, usually within a few minutes, so a successful call reports the matched persons in persons_queued_for_deletion and persons_deleted stays 0. Treat persons_queued_for_deletion as the success signal, not persons_deleted. The endpoint reports failures in deletion_errors rather than with an error status, so check that list: a 202 with entries means those persons were not deleted and you should retry them.

FieldTypeDescription
persons_foundintegerNumber of persons matched by the provided IDs or distinct IDs
persons_queued_for_deletionintegerNumber of persons queued for deletion in the background. Their person records and distinct IDs are removed shortly after the request completes. 0 if keep_person was set to true
persons_deletedintegerNumber of person records deleted during the request itself. 0 when the deletion was queued or keep_person was set to true
events_queued_for_deletionbooleanWhether event deletion was queued for the matched persons
recordings_queued_for_deletionbooleanWhether recording deletion was queued for the matched persons
deletion_errorsarrayPersons whose deletion did not complete during the request, each containing person_uuid and the step that failed. Always empty when the deletion was queued

Deleting a single person with DELETE /api/projects/:project_id/persons/:id still removes the person during the request and returns an empty 202.

Checking deletion status

Event deletions run asynchronously during non-peak hours. To check the status of queued event deletions, use the deletion status endpoint:

export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
"https://us.posthog.com/api/projects/:project_id/persons/deletion_status?status=pending"

Query parameters:

  • status - Filter by pending, completed, or all (default: all)
  • person_uuid - Filter by a specific person UUID

Response fields:

FieldTypeDescription
person_uuidstringThe UUID of the person whose events are queued for deletion
created_atstringWhen the deletion was requested (ISO 8601)
statusstringCurrent status: pending or completed
delete_verified_atstringWhen the deletion was verified complete, or null if still pending

Manual data deletion

You can manually delete persons and their events in the PostHog UI:

  • Select Persons from the left-hand menu
  • Search for the person via their distinct_id or a property like email.
  • Click view next to the person within the search results
  • Click Delete person to remove them and all their associated data from the PostHog instance. You will be prompted to confirm this action.

Deleting events without a person profile

Person deletion removes events by person. Events captured without a person profile, such as anonymous events, have no person to delete, so the person deletion tools can't remove them on their own.

To delete all the events for one distinct ID, give the distinct ID a person profile first, then delete that person:

  1. Send a $set event for the distinct ID with the capture API. This creates a person profile for the distinct ID, and its existing events and recordings are linked to that person. Send it from your server or with curl, because the JavaScript Web SDK ignores person calls when person_profiles is set to 'never'.
  2. Check that the person exists by calling GET /api/projects/:project_id/persons/?distinct_id=<distinct_id> with a personal API key. If results is empty, the $set event hasn't been processed yet, so wait a minute and check again.
  3. Call the bulk delete endpoint with the distinct ID in distinct_ids, delete_events: true, and delete_recordings: true. This deletes the person you just created, along with its events and recordings.
  4. Check the deletion status. The events are deleted once delete_verified_at has a value.

Like other event deletions, the events are deleted asynchronously.

Deleting specific events

To delete events that match more specific criteria, such as events from a specific date range or events with specific properties, contact support and include:

  • Your project ID
  • How to find the events, such as an event name, property filters, a date range, or a SQL query
  • How many events you expect the deletion to match

Support can request the deletion for you, or turn on event deletion in the PostHog app for your organization. Like other event deletions, it runs asynchronously.

What deleting a person doesn't remove

Deleting a person, along with their events and recordings, doesn't remove every copy of their data:

  • AI events: person deletion removes the person's $ai_ events from the events table, but not the full copy PostHog keeps in ai_events, which includes prompts and outputs. That copy is deleted after 30 days.
  • Heatmaps: heatmap data can't be deleted per person. It expires after 90 days.
  • PostHog AI chats: chats that quote the person's data stay until the chat's user, project, or organization is deleted.
  • Events without a person profile: see deleting events without a person profile.
  • Backups: deleted data stays in backups until they expire.
  • Data you've sent elsewhere: data that batch exports or destinations already sent to other tools stays there. Delete it in those tools.

When expired events are deleted

PostHog doesn't delete events as soon as they pass your retention period. A cleanup runs once a month and deletes a whole calendar month of events at a time, once every event in that month has expired. This means events from early in a month stay longer than events from late in the month, and an event can stay for up to about two months past your retention period.

Deleted events also stay in backups for about two weeks.

Asynchronous data deletion

While most data in PostHog is deleted instantly, event data is not. Instead, event data is cleared asynchronously during non-peak usage times (weekends on PostHog Cloud). The request cutoff time for each batch deletion is two days before the batch runs. Deletion requests that miss the cutoff time will be included in the batch after next.

This is done because data deletion in ClickHouse is expensive and it can impact performance for other users.

Data access control

An important part of protecting your users' privacy is to control who can access what data in PostHog. PostHog provides access control at 3 levels:

  1. Organization level
  2. Project level
  3. Resource level

It's up to you to use these access control features to grant access to only the people who need to access the data.

You can follow this comprehensive guide to access control to learn more.

Still have questions?

Was this page useful?