Goals & events
BetaTwo endpoints: your site’s custom events with their completions and visitors, and its goals with their conversions and rate, as the Overview’s Goals & events panel counts them.
Parameters
Both endpoints take the same parameters.
today, yesterday, 7d, 30d, 90d, 52w, or a range of days or hours. The last 30 days if left out. PeriodsAmerica/New_York. The site’s own if left out.country=SE. They combine. FiltersNeither compares periods, so sending against returns a 400. To compare two periods, ask for each one.
Request
Both endpoints for an example site, the last 30 days. Each request counts toward your workspace’s hourly limit on its own.
curl -G https://app.lyli.io/api/v1/sites/s_k3m9x2p7qa/events \
-H "Authorization: Bearer $LYLI_API_KEY" \
-d period=30d \
-d timezone=Europe/Stockholm
curl -G https://app.lyli.io/api/v1/sites/s_k3m9x2p7qa/goals \
-H "Authorization: Bearer $LYLI_API_KEY" \
-d period=30d \
-d timezone=Europe/Stockholm// Node 18 or later, on your server
const site = "https://app.lyli.io/api/v1/sites/s_k3m9x2p7qa";
const params = new URLSearchParams({ period: "30d", timezone: "Europe/Stockholm" });
const read = async (report) => {
const res = await fetch(`${site}/${report}?${params}`, {
headers: { Authorization: `Bearer ${process.env.LYLI_API_KEY}` },
});
if (!res.ok) throw new Error(`Lyli API: ${res.status}`);
return res.json();
};
const [{ events }, { goals }] = await Promise.all([read("events"), read("goals")]);import os
import requests
site = "https://app.lyli.io/api/v1/sites/s_k3m9x2p7qa"
params = {"period": "30d", "timezone": "Europe/Stockholm"}
headers = {"Authorization": f"Bearer {os.environ['LYLI_API_KEY']}"}
res = requests.get(f"{site}/events", params=params, headers=headers, timeout=10)
res.raise_for_status()
events = res.json()["events"]
res = requests.get(f"{site}/goals", params=params, headers=headers, timeout=10)
res.raise_for_status()
goals = res.json()["goals"]Response
Custom events
{
"site": "s_k3m9x2p7qa",
"period": {
"key": "30d",
"from": "2026-10-24",
"to": "2026-11-22",
"timezone": "Europe/Stockholm",
"interval": "day"
},
"events": [
{
"name": "signup_completed",
"completions": 22,
"visitors": 22,
"revenue": null
},
{
"name": "trial_started",
"completions": 10,
"visitors": 10,
"revenue": null
},
{
"name": "newsletter_subscribed",
"completions": 8,
"visitors": 8,
"revenue": null
},
{
"name": "docs_search",
"completions": 4,
"visitors": 4,
"revenue": null
},
{
"name": "outbound_link",
"completions": 4,
"visitors": 4,
"revenue": null
},
{
"name": "subscription_started",
"completions": 3,
"visitors": 3,
"revenue": { "amount": 609, "currency": "EUR" }
}
]
}An example site’s numbers.
null when none were sent with it in the period.Goals
{
"site": "s_k3m9x2p7qa",
"period": {
"key": "30d",
"from": "2026-10-24",
"to": "2026-11-22",
"timezone": "Europe/Stockholm",
"interval": "day"
},
"goals": [
{
"id": "g_pdcf2qka2r",
"name": "Signup",
"kind": "event",
"match": "signup_completed",
"key_goal": true,
"completions": 22,
"conversions": 22,
"rate": 8.4,
"revenue": null
},
{
"id": "g_nzp66gu8st",
"name": "Trial started",
"kind": "event",
"match": "trial_started",
"key_goal": false,
"completions": 10,
"conversions": 10,
"rate": 3.8,
"revenue": null
},
{
"id": "g_uvhvrnb6do",
"name": "Viewed pricing",
"kind": "page",
"match": "/pricing",
"key_goal": false,
"completions": 117,
"conversions": 108,
"rate": 41.4,
"revenue": null
}
]
}The same example site’s goals.
event for a custom event goal, page for a page goal.*.true for the site’s key goal, the one marked Key goal in Goals & events and on the Overview’s Goals & events panel.null when the period has no visitors./events. null for page goals.How it’s counted
Both count what the Overview’s Goals & events panel shows for the same period and filters: the visits that match your filters, segment, and cohort, and nothing else.
- Rates are of the visitors you read. With
country=SE, a goal’s rate is its Swedish conversions as a share of Swedish visitors. - An event can show 0 completions. It stays in the list when the site sent it but none of the visits you read did, such as under a filter.
- Page goals ending in * count every page whose path starts with what comes before the
*:/blog/*counts/blog/launch. - Revenue is in the site’s currency, set in Site settings. An amount sent in another currency is converted at the European Central Bank’s rate from the last day it published before the payment. An amount we can’t read, or in a currency with no rate, isn’t counted in revenue, but the event still is. Currencies and refunds
- Event properties aren’t in either response.
- History imported from Google Analytics isn’t in either response. In the app, Goals & events adds it, so for days an import covers, the app can show more than the API.
Errors
against, a segment or cohort the site doesn’t have, or a period, filter, or time zone we can’t parse.Every endpoint can also return 401 (missing, revoked, or expired key) and 429 (rate limit reached). All errors
Start from a report
On the site’s Goals & events page, under Behavior, Copy as API request in the Share menu copies both requests as curl, a blank line apart, with the period, filters, segment, cohort, and time zone you’re looking at. They read your API key from the LYLI_API_KEY environment variable, so a copied request never contains a key.
A single event’s or goal’s page has no request: the API has no endpoint for one event. An AI assistant connected with MCP can read one with get_event.