Skip to content

trackr.link form endpoint

Post a website form to trackr.link from HTML, JavaScript or a server: the endpoint, the body types and fields, every answer, the spam checks and the limits.

Each form you create in trackr.link has its own endpoint. A website posts to it as it would to any form backend, from a plain HTML form, from JavaScript or from a server. trackr.link stores each submission as a lead in the Leads inbox, emails it to the form's recipients, and credits it to the visit that brought the person to your site. The OpenAPI document at https://trackr.link/openapi.json describes the endpoint as submitForm.

Endpoint

POST https://forms.trackr.link/f/YOUR_FORM_ID

Replace YOUR_FORM_ID with the id of your form. The form's page in trackr.link shows its endpoint URL, and the HTML and JavaScript below with the id filled in. The id never changes, so the endpoint stays the same while the form exists.

The endpoint needs no token and sets no cookies. It answers requests from any origin, including the CORS preflight that a JSON body from a browser sends.

Send a plain HTML form

This form works without JavaScript:

<form action="https://forms.trackr.link/f/YOUR_FORM_ID" method="POST">
  <label>Name <input type="text" name="name" required></label>
  <label>Email <input type="email" name="email" required></label>
  <label>Phone <input type="tel" name="phone"></label>
  <label>Message <textarea name="message" required></textarea></label>
  <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
  <button type="submit">Send</button>
</form>

After sending, the browser goes to the form's redirect URL, or to a thank-you page on trackr.link when the form has none. Set the redirect URL in the form's settings. No field can change it.

Add, rename or remove any other field. Keep the names email and name on the fields that ask for them, and keep _gotcha hidden and empty.

Send it with JavaScript

To keep the visitor on the page, send the form with fetch and read the JSON answer:

document.querySelector('form').addEventListener('submit', async (event) => {
  event.preventDefault();

  const response = await fetch('https://forms.trackr.link/f/YOUR_FORM_ID', {
    method: 'POST',
    headers: { Accept: 'application/json' },
    body: new URLSearchParams(new FormData(event.target)), // Sends each field under the name it has here.
    referrerPolicy: 'no-referrer-when-downgrade', // Names the page the lead was sent from.
  });
  const result = await response.json();

  // result.ok is true once the lead is received. Otherwise result.error says why.
});

The Accept: application/json header asks for a JSON answer instead of a redirect. URLSearchParams sends the fields URL-encoded, so each keeps the name it has in the form. The referrerPolicy option sends the address of the page, so the lead shows the page it was sent from. A plain HTML form usually does not.

Send it from a server

A post from your server has no Origin or Referer header and the user agent of an HTTP library, so the form puts it in spam. In the form's settings, check Accept any domain, and the form skips both checks. Then post JSON:

curl https://forms.trackr.link/f/YOUR_FORM_ID \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"name": "Ada Lovelace", "email": "[email protected]", "message": "Hello"}'

Every post from one server counts as one visitor, so the server can send a form 10 times a minute. A lead from a server has no visit and no source.

Body

The endpoint reads three body types:

  • application/x-www-form-urlencoded, which a plain HTML form and the example above send.
  • multipart/form-data, which fetch sends with a FormData body on its own. The endpoint ignores uploaded files.
  • application/json, with an object of fields.

It ignores the query string. A submission may hold up to 50 fields, 10,000 characters in a value and 100 KB in all, counted over the names and values of the fields it stores. A larger submission is refused, and so is one where no stored field has a value.

Fields

  • Every field is stored under the name the page gives it, in the order it was sent.
  • A group of values, such as checkboxes named topics[], is stored as one field named topics, with its values joined by commas. A URL-encoded body joins the values of a name it sends twice the same way. In JSON, a list is joined the same way, true and false are stored as words, and null as an empty value.
  • In a multipart/form-data body, a space or a dot in a field's name becomes _, and a name sent twice without [] keeps only its last value. To keep a name such as First Name as it is, send the body URL-encoded or as JSON.
  • email, matched without regard to case, becomes the reply-to address of the email to the recipients when its value is a valid email address. It also finds one person's leads when they ask you to export or delete them.
  • name, matched the same way, labels the lead in the inbox and in the subject of the email.
  • A field whose name starts with _ is not stored, and neither is cf-turnstile-response.
  • _gotcha is the honeypot. People never see it, and a bot fills it in. A submission with a value in it is dropped and gets the answer of a stored lead.

A form must not collect passwords, payment card numbers, government ID numbers, health data or other special categories of personal data. The Terms forbid it.

Answers

A request whose Accept header asks for application/json gets JSON. Any other request, such as a plain HTML form, gets a redirect or a page.

When Status error
The submission is stored as a lead, held or flagged as spam, or the honeypot dropped it 200 None. The answer is {"ok": true}.
The form is disabled, or its site's recording is stopped 403 This form is closed and no longer accepts submissions.
The submission has more than 50 fields, a value over 10,000 characters, or more than 100 KB in all 422 The submission is too large. A form takes up to 50 fields, 10,000 characters in a field and 100 KB in all.
No field the form stores has a value 422 The submission is empty. Fill in the form and send it again.
The visitor sent the form 10 times in the last minute 429 You sent this form too many times in a minute. Wait a minute and send it again.
The form uses Turnstile, and Cloudflare did not verify the response, there is none, or Cloudflare could not be reached 422 The form could not verify that you are a person. Go back, wait for the check to finish and send the form again.
No form has the id, or the form is deleted 404 None

A refused submission answers {"ok": false, "error": "…"} with the error above. Without JSON, a stored submission answers 303 and sends the browser on, and a refused one answers with its status and a page that shows the error and links back to the site.

The answer to a lead, a held lead and spam is the same, so whoever sent it cannot tell which check caught it.

How a submission is checked

The endpoint checks each submission in this order, and stops at the first check that refuses it:

  1. A disabled form, or a form whose site's recording is stopped, refuses the submission with 403.
  2. A value in _gotcha drops the submission, with the answer of a stored lead.
  3. A submission that is too large or empty is refused with 422.
  4. On a form that uses Turnstile, a submission whose response Cloudflare does not verify is refused with 422.
  5. A visitor who sent the form 10 times in the last minute is refused with 429. The limit counts per form and visitor. Spam counts toward it, and a submission refused by an earlier check does not.
  6. A bot's user agent, such as a crawler's, an HTTP library's or a headless browser's, puts the submission in spam.
  7. So does a post whose Origin host, or Referer host when Origin is missing, is not the site's domain, one of its subdomains, one of the form's other domains or localhost. A post with neither header is spam too.
  8. When the plan holds leads and the month's leads are used up, the lead is held.

Otherwise the lead goes to the inbox and is emailed. Spam is not emailed or counted, and it is deleted after 30 days unless someone marks it "Not spam". A form set to Accept any domain skips checks 6 and 7.

Allowed domains

A post from a page on the form's site, its subdomains or localhost reaches the inbox. When the form is on another domain too, add it under Other domains in the form's settings, up to 20 of them. Its subdomains count too.

A browser sets the Origin header itself, so a page on another site cannot fake it. A script that posts from a server can send any header, so the domain check keeps out mistakes and simple bots, but not a sender who sets out to pass it. Turnstile is the stronger check.

Turnstile

For a form that still gets spam, check Check with Cloudflare Turnstile in its settings, and paste the secret key of your own Turnstile widget. Then add Cloudflare's script to the page and the widget to the form, with your widget's site key:

<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
<div class="cf-turnstile" data-sitekey="your-site-key"></div>

The widget adds its response to the form as cf-turnstile-response. trackr.link sends Cloudflare only that response and your secret key, never the visitor's IP address or the fields. Cloudflare verifies a response once, so a page that sends with fetch must call turnstile.reset() after each send. The fetch example on the form's page does this when Turnstile is on.

A submission without a response that Cloudflare verifies is refused with 422, and so is every submission while Cloudflare cannot be reached. The person can wait for the check and send the form again.

Content-Security-Policy

A page with a Content-Security-Policy must allow the endpoint:

  • form-action needs https://forms.trackr.link for a plain HTML form. Chrome also applies form-action to the redirect after the post, so it needs the host of your redirect URL too.
  • connect-src needs https://forms.trackr.link when the page sends with fetch.
  • With Turnstile, script-src and frame-src need https://challenges.cloudflare.com.

The page a lead was sent from

trackr.link reads the page a lead was sent from in the Referer header, and stores its host and path without the query string. By default, a browser sends only the origin in Referer with a post to another site. A plain HTML form on https://example.com/contact therefore reports /, and the dashboard counts its leads on the home page.

The fetch example sets referrerPolicy on its own request, which sends the full address. For a plain HTML form, add this tag to the head of the page:

<meta name="referrer" content="no-referrer-when-downgrade">

The tag applies to every request the page makes, so the page also sends its full address, query string included, to the other sites it loads files from.

Where a lead comes from

On a page with the trackr.link snippet, trackr.link computes the visitor's daily hash from the post, as it does for a pageview, and credits the lead to the visitor's latest visit in the 24 hours before it, preferring any channel over Direct. It also credits the lead to the last of the team's short links to the site that the visitor opened in that time. The IP address and user agent are used in memory and not stored with the lead.

The hash matches only when the person sends the form from the device and network of their visit, on the same day in the site's time zone. A lead from a page without the snippet has no visit and no source.

Limits

  • Size: up to 50 fields, 10,000 characters in a value and 100 KB in all.
  • Rate: 10 submissions a minute for each form and visitor.
  • Recipients: up to 10 addresses a form.
  • Retention: each form keeps its leads for 30 days, 90 days, 1 year or 2 years, or until you delete them, and a new form keeps them for 1 year.

For forms, the plans differ only in how many you can make and how many leads a month they deliver:

Plan Forms Leads a month Leads past the limit
Free 1 50 Held until you move to a plan with room for them
Pro 10 1,000 Delivered
Business 100 5,000 Delivered

A form accepts every submission that is not spam, whatever the plan. On Free, a lead past the month's limit is held: it is not emailed, and the inbox shows only the first letters of its name or email until the owner moves to a plan with room for it. Only Free can be started today. Pro and Business are coming soon and cannot be bought or started yet. See pricing.

Free for one site. No credit card.

Create free account