> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Sensitive data and tracking Canonical URL: https://posthog.com/docs/workflows/transactional/sensitive-data > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.posthog.com` instead of `https://us.posthog.com` (app host for links). 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](https://posthog.com/docs/workflows/transactional/send-from-code.md#send-the-html) take `tracking`: | `tracking` | Opens | Clicks | Engagement events | | --- | --- | --- | --- | | Left out | On | The template's setting. Without one, off when sensitive and on otherwise. | On | | `true` | On | On | On | | `false` | Off | Off | Off | | An object with `opens`, `clicks`, and `engagement` | Your choice | Your choice | Your choice | A kind that the object leaves out keeps its default. For example, to send an email with no secrets and track its clicks: ### Node.js ```javascript await posthog.emails.send({ to: "ada@example.com", templateKey: "order-shipped", subject: "Your order shipped", html, sensitive: false, tracking: { clicks: true }, }) ``` ### Python ```python posthog.emails.send( to="ada@example.com", template_key="order-shipped", subject="Your order shipped", html=html, sensitive=False, tracking={"clicks": True}, ) ``` ### Ruby ```ruby $posthog.emails.send( to: 'ada@example.com', template_key: 'order-shipped', subject: 'Your order shipped', html: html, sensitive: false, tracking: { clicks: true } ) ``` ### Rust ```rust posthog .emails() .send( CodeEmail::new("ada@example.com", "order-shipped", "Your order shipped") .html(html) .sensitive(false) .tracking(EmailTrackingOptions::new().clicks(true)), ) .await?; ``` ### PHP ```php PostHog::emails()->send([ 'to' => 'ada@example.com', 'template_key' => 'order-shipped', 'subject' => 'Your order shipped', 'html' => $html, 'sensitive' => false, 'tracking' => ['clicks' => true], ]); ``` ### Go ```go _, err := client.Emails().Send(ctx, posthog.CodeEmail{ To: "ada@example.com", TemplateKey: "order-shipped", Subject: "Your order shipped", HTML: html, Sensitive: posthog.Ptr(false), Tracking: posthog.EmailTrackingWith(posthog.EmailTrackingOptions{Clicks: posthog.Ptr(true)}), }) ``` ### .NET ```csharp await emails.SendAsync(new SendCodeEmailOptions { To = "ada@example.com", TemplateKey = "order-shipped", Subject = "Your order shipped", Html = html, Sensitive = false, Tracking = new EmailTracking { Clicks = true }, }); ``` ### Elixir ```elixir PostHog.Emails.send( to: "ada@example.com", template_key: "order-shipped", subject: "Your order shipped", html: html, sensitive: false, tracking: %{clicks: true} ) ``` ### REST ```bash curl -X POST "https://us.posthog.com/api/messaging/send/email/" \ -H "Authorization: Bearer $POSTHOG_PROJECT_SECRET_API_KEY" \ -H "Content-Type: application/json" \ -d '{"template_key": "order-shipped", "to": "ada@example.com", "subject": "Your order shipped", "html": "
Your order shipped.
", "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 `` 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](https://posthog.com/docs/workflows/email/engagement-events.md) are on for your project. If they're off for the project, `tracking` can't turn them on.