Conversion tracking
See which clicks led to a sign-up or a sale, and what they were worth.
Business plan. Conversion tracking tells you which clicks turned into results on your own website, such as a sign-up, a booking or a sale, and what they were worth. You see conversions next to your clicks, for each link and each campaign.
How it works
- You turn on conversion tracking for a link.
- When someone follows the link, we add a click ID to the destination address, as
bgl_click. - Your website keeps that click ID while the visitor looks around, signs up or checks out.
- When they convert, your server sends the click ID to us with the conversions API, saying what happened.
- The conversion appears in your analytics against the link and its campaign.
You'll need someone who can change your website and its server code. It's usually an hour or two of work.
Turn it on for a link
- Open the link's page in Links (or open More options when creating a link).
- Tick Track conversions and save. The link's page shows Tracking conversions.
- Follow the link yourself. The address you land on now ends with a click ID:
The address the visitor lands on
https://example.com/spring-sale?bgl_click=AQAAAAAAAAAqZxH3kQ8b2mVtPq7rWw
Any query string already on the destination, and the visitor's own parameters, stay as they are. With the API, set trackConversions to true when creating or changing a link.
Check your site accepts it
Most sites ignore address parameters they don't know. If your page shows an error or drops the parameter on a redirect (for example from http to https, or to add www), point the link at the final address instead.
Keep the click ID on your site
The click ID only arrives on the first page. Keep it until the visitor converts, which may be several pages or days later. The usual way is a first-party cookie, set by a few lines on your landing page:
HTML, on your landing page
<script>
// Keep the click ID for 90 days, so a later sign-up or purchase still counts.
const click = new URLSearchParams(location.search).get("bgl_click");
if (click) {
document.cookie = "bgl_click=" + encodeURIComponent(click) +
"; Max-Age=7776000; Path=/; SameSite=Lax; Secure";
}
</script>
Then send it with the sign-up or order, for example as a hidden form field:
HTML, on your sign-up or checkout form
<form method="post" action="/signup">
<!-- … your fields … -->
<input type="hidden" name="bgl_click" id="bgl_click">
</form>
<script>
const m = document.cookie.match(/(?:^|; )bgl_click=([^;]*)/);
if (m) document.getElementById("bgl_click").value = decodeURIComponent(m[1]);
</script>
- If the visitor signs up straight away, you can instead read
bgl_clickfrom the address on the server and keep it in their session. - For purchases that complete later (such as a bank transfer), store the click ID with the order and report the conversion when it's paid.
- If the visitor arrives through several tracked links, keep the most recent click ID, or the first, depending on which you want to credit. Be consistent.
Report conversions from your server
When the visitor converts, your server calls the API. Send it from your server, never from the browser, so your API key stays secret.
- Create an API key in API keys with the Record conversions permission (
conversions:write). See API quick start. - When someone signs up or pays, send the click ID and what happened:
curl
curl -X POST "https://bgum.me/api/v1/workspaces/$WORKSPACE_ID/conversions" \ -H "Authorization: Bearer $BGL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "click": "AQAAAAAAAAAqZxH3kQ8b2mVtPq7rWw", "event": "purchase", "value": 49.95, "currency": "AUD", "eventId": "order-1042" }'JavaScript
const res = await fetch(`https://bgum.me/api/v1/workspaces/${process.env.WORKSPACE_ID}/conversions`, { method: "POST", headers: { Authorization: `Bearer ${process.env.BGL_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "click": "AQAAAAAAAAAqZxH3kQ8b2mVtPq7rWw", "event": "purchase", "value": 49.95, "currency": "AUD", "eventId": "order-1042" }), }); if (!res.ok) throw new Error(`${res.status} ${await res.text()}`); const data = await res.json(); console.log(data);Python
import os import requests res = requests.post( f"https://bgum.me/api/v1/workspaces/{os.environ['WORKSPACE_ID']}/conversions", headers={ "Authorization": f"Bearer {os.environ['BGL_API_KEY']}", }, json={ "click": "AQAAAAAAAAAqZxH3kQ8b2mVtPq7rWw", "event": "purchase", "value": 49.95, "currency": "AUD", "eventId": "order-1042", }, timeout=30, ) res.raise_for_status() print(res.json()) - You get
201 Createdback. If the call fails because of a network problem, send it again with the sameeventId: a repeat returns200with the first record, so nothing is counted twice.
| Field | What to send |
|---|---|
click | The bgl_click value, exactly as it arrived. |
event | What happened, such as signup, trial or purchase. Use the same few names every time; reports group by them. |
value and currency | Optional, but always together: 49.95 and AUD. Totals are kept per currency. |
eventId | Recommended: your order or account number, so retries aren't counted twice. |
occurredAt | Optional: when it happened, if not now. |
A conversion counts if it happens within 90 days of the click. Full details are in the API reference.
Read your results
- A link's page and Analytics show Conversions, the Conversion rate (conversions per click from people in the same period) and the total Value per currency.
- Conversions are broken down by event, and on Analytics by campaign too. A conversion is credited to the campaign the link was in when it was clicked.
- Conversions are counted on the day they happen, in the workspace's analytics time zone, so a click on Monday and a sale on Friday show the sale on Friday.
- The CSV export has a
conversionscolumn. See CSV export.
Privacy
- A click ID says which link was followed and when. It contains nothing about the visitor, and we don't set any cookies ourselves.
- Click IDs are signed, so they can't be guessed or altered.
- If you store the click ID in a cookie, treat it like your other analytics cookies in your privacy policy and cookie notice.
- Don't send personal details, such as names or email addresses, in
eventoreventId.
Common problems
| Problem | What to check |
|---|---|
No bgl_click on the landing page | Check Track conversions is ticked and saved. Check your site doesn't drop query parameters when it redirects. |
conversion.click_invalid | Send the value exactly as it arrived. Don't decode, trim or shorten it. |
conversion.click_not_found | The link belongs to another workspace. Use an API key for that workspace. |
conversion.outside_window | The conversion was more than 90 days after the click, so it isn't counted. |
plan.feature_required | Conversion tracking needs the Business plan. |
access.forbidden | The API key needs the conversions:write scope, and its creator needs the Manager role or above. |
| Conversions counted twice | Send an eventId with each conversion. |
Something missing or unclear? Tell us and we'll improve this page.