Sensitive data and tracking

Sign-in codes, reset links, and magic links are secrets. Mark those emails as sensitive, and PostHog handles them more carefully.

Protect sensitive data

For a sensitive email, PostHog:

  • Keeps links direct. Click tracking is off by default, so a token never goes through a redirect. If you turn click tracking on, PostHog records only the site address of a clicked link, not the full link.
  • Keeps no copy. It doesn't store the subject or body. The Log says so instead of showing the email.
  • Leaves the subject off events. Engagement events don't carry it.

PostHog still tracks deliveries, opens, bounces, and the status.

Templates: turn on Protect sensitive data when you create the email, or later on its API tab. Under it, Track link clicks turns click tracking on for links that carry no secrets.

HTML from your code: send sensitive. If you leave it out, the email takes the setting of the template with the same key, or is sensitive when there isn't one. Send "sensitive": false for an email with no secrets, such as an order confirmation, so its clicks are tracked. A send can't set false when the template with the same key is sensitive.

Tracking

send emails from code take tracking:

trackingOpensClicksEngagement events
Left outOnThe template's setting. Without one, off when sensitive and on otherwise.On
trueOnOnOn
falseOffOffOff
An object with opens, clicks, and engagementYour choiceYour choiceYour choice

A kind that the object leaves out keeps its default.

For example, to send an email with no secrets and track its clicks:

await posthog.emails.send({
to: "ada@example.com",
templateKey: "order-shipped",
subject: "Your order shipped",
html,
sensitive: false,
tracking: { clicks: true },
})
  • A sensitive email with safe links: send "tracking": {"clicks": true} to count clicks and keep the other protections.
  • One link untracked: add data-ph-no-track to its <a> tag. Use this for app deep links, which break when rewritten.
  • Clicks need opens: PostHog refuses {"opens": false, "clicks": true}.

A template send uses the template's own settings, so it takes neither sensitive nor tracking.

Opens and clicks only become events when engagement events are on for your project. If they're off for the project, tracking can't turn them on.

Still have questions?

Was this page useful?