Skip to content

Domain with DNS elsewhere (CNAME)

The CNAME kind (DNS stays elsewhere (CNAME) in the add dialog) lets you use a tracking hostname whose DNS is managed outside the installation’s Cloudflare account, at any DNS provider. The domain owner adds a single CNAME record; amabledata registers the hostname as a Cloudflare for SaaS custom hostname and Cloudflare issues its certificate automatically. The in-app description reads: The domain owner only adds a CNAME; the certificate is issued automatically.

This kind must be enabled by whoever operates the installation. When it is not, the option is disabled in Add a tracking domain with the text Not configured on this installation: the domain must be a zone of this Cloudflare account. Use the zone kind in that case.

Domains are managed in Analytics settings › Domains (/t/<workspace>/analytics/settings?tab=domains). See the Tracking domains overview for the shared concepts.

The core worker needs three settings (see Configuration):

Setting Type Value
CF_ZONE_ID Variable The id of the Cloudflare zone that serves the tracking worker and on which the custom hostnames are created.
CF_API_TOKEN Secret (wrangler secret put CF_API_TOKEN) An API token with the permission SSL and Certificates: Edit on that zone.
TRACKING_CNAME_TARGET Variable, optional The hostname customers point their CNAME at. Default: the host of the edge worker’s public origin (EDGE_ORIGIN).

The option becomes available as soon as CF_ZONE_ID and CF_API_TOKEN are both set. Cloudflare for SaaS custom hostnames must be available on that zone, and traffic for the custom hostnames must reach the tracking worker on it; set this up following Cloudflare’s Cloudflare for SaaS documentation.

On the managed cloud this is decided by the operator. In development installations a simulated provider is used instead of Cloudflare.

  1. amabledata creates a custom hostname on the zone, with a domain-validated certificate validated over HTTP and a minimum TLS version of 1.2.
  2. If Cloudflare refuses or cannot be reached, nothing is saved and you see The certificate service did not answer. Try again in a moment.
  3. Otherwise the domain is listed with the records to create at your DNS provider.

While the domain is not active, its row shows Create these records at your DNS provider (CNAME not proxied), then press “Check now”. The certificate is issued automatically. and:

Type Name Value
CNAME Your hostname, e.g. track.example.com The tracking target (TRACKING_CNAME_TARGET)
TXT Shown only when Cloudflare asks for it The validation token given by Cloudflare

Each line has Copy name and Copy value. The TXT line appears when Cloudflare returns an ownership verification record or a certificate validation record.

amabledata maps Cloudflare’s hostname status and certificate status onto the domain status:

Cloudflare hostname status Cloudflare certificate status Domain status
blocked, moved, deleted, test_failed any Error
anything other than active any Waiting for DNS
active active Active
active initializing, pending_validation, pending_issuance, pending_deployment, pending_cleanup Issuing certificate
active any other value Error

The error text shown under the domain is, in order of preference: Cloudflare’s certificate validation error, Cloudflare’s hostname verification error, or <hostname status>/<certificate status> when the status is an error without a message. It is shown as Cloudflare wrote it, truncated to 300 characters. If Cloudflare no longer knows the hostname, the domain becomes Error with hostname_unknown_to_provider.

Check now asks Cloudflare for the current state (and re-creates the custom hostname if it was never created). The core cron, every 5 minutes, also re-checks domains in Waiting for DNS or Issuing certificate whose last check is at least 10 minutes old, and domains in Error whose last check is at least 1 hour old, at most 5 domains per run in total. After fixing an error, click Check now to see the result at once. Domains in Error with site_deleted are not re-checked: the cron only retries their removal.

  1. In the Cloudflare dashboard, open the zone that serves your tracking worker and copy its Zone ID.

  2. Create an API token with Zone › SSL and Certificates › Edit for that zone.

  3. Set the settings on the core worker:

    Terminal window
    cd apps/core
    wrangler secret put CF_API_TOKEN

    and add CF_ZONE_ID (and optionally TRACKING_CNAME_TARGET) to the vars of the core worker, or in the Cloudflare dashboard under the core worker’s Settings › Variables and secrets.

  4. Deploy. In Analytics settings › Domains, the DNS stays elsewhere (CNAME) option is now selectable.

  1. Open Analytics settings › Domains, pick the site and click Add domain.
  2. Type the Hostname (a subdomain you control, e.g. track.example.com).
  3. Select DNS stays elsewhere (CNAME) and click Add.
  4. At your DNS provider, create the CNAME record shown, not proxied if your provider offers a proxy. Create the TXT record too when it is shown.
  5. Wait, or click Check now. The status moves from Waiting for DNS to Issuing certificate, then to Active.
Item Value
Kind cname
Required settings CF_ZONE_ID, CF_API_TOKEN
Optional setting TRACKING_CNAME_TARGET (default: edge origin host)
Token permission SSL and Certificates: Edit, on the zone
Certificate Domain-validated, HTTP validation, TLS 1.2 minimum
Records CNAME to the tracking target; TXT when asked
Statuses Waiting for DNS, Issuing certificate, Active, Error
Error text length 300 characters

In development installations the simulated provider advances one step at every check (Waiting for DNS → Issuing certificate → Active) and shows a sample TXT record named _cf-custom-hostname.<hostname>.

  • Adding, checking and deleting need analytics:configure (owner, admin, marketer).
  • Deleting a CNAME domain also deletes the custom hostname at Cloudflare. If Cloudflare refuses, the deletion fails with The certificate service did not answer. Try again in a moment. and the domain stays listed. If the settings were removed from the installation, checks and deletions answer Custom tracking domains are not configured on this installation.
  • The hostname rules of the overview apply. The tracking target itself and its subdomains cannot be added.
Symptom or message Cause Fix
Option disabled: Not configured on this installation: the domain must be a zone of this Cloudflare account. CF_ZONE_ID or CF_API_TOKEN is missing. Configure both, or use the zone kind.
Custom tracking domains are not configured on this installation. Same, reached through Check now, delete or the API. As above.
The certificate service did not answer. Try again in a moment. when adding Cloudflare API unreachable, wrong zone id (zone not found), token without permission, or the hostname is refused by Cloudflare. Check the zone id and token permission; retry.
Stays on Waiting for DNS The CNAME is missing, wrong, proxied by another provider, or not propagated; the TXT record is missing. Fix the records; the cron keeps checking.
Stays on Issuing certificate Cloudflare is validating or deploying the certificate. HTTP validation needs the CNAME to resolve to Cloudflare. Wait; keep the CNAME in place. The cron keeps checking.
Error with a Cloudflare message Cloudflare blocked the hostname or the certificate validation failed. Fix what the message says, then Check now.
Error with hostname_unknown_to_provider The custom hostname was deleted on Cloudflare’s side. Delete the domain and add it again.
Error with site_deleted The site was deleted and the custom hostname could not be removed yet. Nothing to do: the cron retries the removal.