Skip to content

Goals & events

Beta

Two 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.

GET/api/v1/sites/{site}/events
GET/api/v1/sites/{site}/goals

Parameters

Both endpoints take the same parameters.

NameWhat it does
siteIn the path, requiredThe site’s ID. Sites lists the ones your key can read.
periodOptionaltoday, yesterday, 7d, 30d, 90d, 52w, or a range of days or hours. The last 30 days if left out. Periods
timezoneOptionalA time zone name, such as America/New_York. The site’s own if left out.
channel … contentOptionalAny of the 14 filters, such as country=SE. They combine. Filters
segment, cohortOptionalA saved segment’s or cohort’s ID.

Neither 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.

Your terminal
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

Response

Custom events

/events · 200 OK · application/json
{
  "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.

FieldWhat it holds
periodThe period read, in the same shape as the Overview’s.
eventsThe site’s custom events in the period, most completions first, then by name.
events[].nameThe event’s name, as your site sends it.
events[].completionsHow many times it was sent.
events[].visitorsDistinct visitors who sent it.
events[].revenueThe amounts sent with it, in the site’s currency, refunds taken off. null when none were sent with it in the period.

Goals

/goals · 200 OK · application/json
{
  "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.

FieldWhat it holds
goalsEvery goal on the site, in the order they were made, including those with no conversions in the period.
goals[].idThe goal’s ID.
goals[].nameIts name, as Goals & events shows it.
goals[].kindevent for a custom event goal, page for a page goal.
goals[].matchThe event’s name, or the page’s path, which may end in *.
goals[].key_goaltrue for the site’s key goal, the one marked Key goal in Goals & events and on the Overview’s Goals & events panel.
goals[].completionsHow many times its event was sent, or how many times its pages were viewed.
goals[].conversionsDistinct visitors who completed it: the panel’s Converted.
goals[].rateConversions as a share of the period’s visitors, in percent. null when the period has no visitors.
goals[].revenueFor a custom event goal, the amounts sent with its event, as in /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

StatusCodeWhen
400invalid_parameteragainst, a segment or cohort the site doesn’t have, or a period, filter, or time zone we can’t parse.
402workspace_pausedThe workspace is paused.
403site_not_allowedYour key doesn’t have access to this site.
404not_foundNo site with this ID in the workspace.

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.