Skip to content

Attribution

Beta

Where a goal’s conversions come from, by channel, source, campaign, medium, and entry page, as the Attribution report counts them. Each visitor counts once, credited to one of their visits.

GET/api/v1/sites/{site}/attribution

Parameters

NameWhat it does
siteIn the path, requiredThe site’s ID, as in its address in the app: app.lyli.io/sites/<id>. /sites lists the ones your key can read.
goalOptionalWhat counts as a conversion: a path, such as /pricing (end it in * for every path that starts with it), or a custom event’s name, such as signup. Pass a goal’s path or event, not its name: goal=subscription_started, not Subscription. The site’s key goal, or its first goal, if left out; needed when the site has no goals.
creditOptionallast or first: which visit gets the credit. last if left out. How credit works
periodOptionaltoday, yesterday, 7d, 30d, 90d, 52w, or a range of days or hours. The last 30 days if left out. Periods
againstOptionalprevious, month, or year. Adds compared to the response.
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.

Request

An example site’s Subscription goal, the custom event subscription_started, over the last 30 days, each visitor credited to their first visit.

Your terminal
curl -G https://app.lyli.io/api/v1/sites/s_k3m9x2p7qa/attribution \
  -H "Authorization: Bearer $LYLI_API_KEY" \
  -d goal=subscription_started \
  -d credit=first \
  -d period=30d \
  -d timezone=Europe/Stockholm

Response

200 OK · application/json
{
  "site": "s_k3m9x2p7qa",
  "period": {
    "key": "30d",
    "from": "2026-10-24",
    "to": "2026-11-22",
    "timezone": "Europe/Stockholm",
    "interval": "day"
  },
  "goal": { "kind": "event", "match": "subscription_started", "name": "Subscription" },
  "credit": "first",
  "totals": {
    "visitors": 447,
    "conversions": 34,
    "revenue": { "amount": 6517, "currency": "EUR" }
  },
  "rows": {
    "channel": [
      { "value": "direct", "visitors": 169, "conversions": 15,
        "revenue": { "amount": 3381, "currency": "EUR" } },
      { "value": "email", "visitors": 76, "conversions": 13,
        "revenue": { "amount": 2401, "currency": "EUR" } },
      { "value": "search", "visitors": 117, "conversions": 3,
        "revenue": { "amount": 147, "currency": "EUR" } }
      // … 3 more rows
    ],
    "source": [
      { "value": "direct", "visitors": 169, "conversions": 15,
        "revenue": { "amount": 3381, "currency": "EUR" } },
      { "value": "newsletter", "visitors": 76, "conversions": 13,
        "revenue": { "amount": 2401, "currency": "EUR" } }
      // … 5 more rows
    ],
    "campaign": [
      { "value": "", "visitors": 371, "conversions": 21,
        "revenue": { "amount": 4116, "currency": "EUR" } },
      { "value": "autumn_launch", "visitors": 76, "conversions": 13,
        "revenue": { "amount": 2401, "currency": "EUR" } }
    ],
    "medium": [
      { "value": "", "visitors": 371, "conversions": 21,
        "revenue": { "amount": 4116, "currency": "EUR" } },
      { "value": "email", "visitors": 76, "conversions": 13,
        "revenue": { "amount": 2401, "currency": "EUR" } }
    ],
    "entry": [
      { "value": "/pricing", "visitors": 158, "conversions": 25,
        "revenue": { "amount": 4753, "currency": "EUR" } },
      { "value": "/", "visitors": 148, "conversions": 6,
        "revenue": { "amount": 1617, "currency": "EUR" } }
      // … 2 more rows
    ]
  },
  "compared": null
}

An example site’s numbers. The lists are shortened here; the response has every row.

FieldWhat it holds
periodThe period read: its first and last day in timezone, and its step, interval, as in the Overview.
goalThe goal: its kind, page or event; its match, the path or the event’s name; and its name when it’s one of the site’s goals, else null.
creditfirst or last, as asked.
totals.visitorsVisitors with a visit in the period, each counted once, whether they converted or not.
totals.conversionsOf them, those who completed the goal in one of those visits.
totals.revenueThe amounts those visitors sent with the goal’s event, in the site’s currency, refunds taken off. null when no completion sent an amount, in the period or the one compared, which is always so for a page.
rowsOne list for each field: channel, source, campaign, medium, and entry. Each visitor is credited to one value of each field.
rows.*.valueThe credited visit’s value: a channel (direct, search, social, referral, email, or ai), a source as the Sources list shows it, a campaign or medium tag ("" for a visit without one), or the entry page’s path. Each is a value its filter takes, except "", which no filter stands for.
rows.*.visitorsThe visitors credited to the value, converted or not.
rows.*.conversionsOf them, those who converted.
rows.*.revenueThe amounts their conversions brought, as in totals. null when totals.revenue is.
comparednull, or with against: the other period’s from, to, and totals. Also null when that period starts before the site’s data does.

How credit works

A visitor counts once either way, so the totals are people, not visits. What changes is which of their visits names the row:

creditCredited visit
lastThe visit they converted in, the earliest if they converted in more than one. For someone who didn’t convert, their last visit in the period. Where people came from when they converted.
firstTheir first visit in the period, whenever they converted. What brought them the first time.
  • On a cookieless site, a visitor’s code lasts a day, so first means their first visit that day, and someone who comes on two days counts as two visitors. For visitors the site recognizes (Recognize returning visitors, with data-remember on the tag once they agree), first can be an earlier day in the period.
  • Filters, a segment, and a cohort narrow the visits first. A visit they leave out is neither credited nor counted as converting.
  • A goal nobody completed returns zero conversions, not an error, so check the event’s name as Goals & events lists it under Custom events, or the goal’s path. Event names match exactly.
  • Each field lists up to 100 values with the most conversions and, when there’s revenue, up to 100 with the most revenue, sorted by conversions, then visitors. To rank by revenue, as the report’s Rank by › Revenue does, sort them yourself.
  • Only what Lyli recorded counts. History imported from Google Analytics isn’t in Attribution, in the app or here.

Rows can be small. An entry page or a campaign can stand for a single visitor, so treat what a key reads as your visitors’ data.

Errors

StatusCodeWhen
400invalid_parameterA parameter it doesn’t take; a goal, credit, period, filter, or time zone we can’t parse; a segment or cohort the site doesn’t have; against=month for a period over 5 weeks; or no goal for a site with no goals yet.
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.

A site with no goals yet, asked without goal:

400 Bad Request
{
  "error": {
    "code": "invalid_parameter",
    "message": "This site has no goals yet: pass goal, a page or a custom event."
  }
}

Every endpoint can also return 401 (missing, revoked, or expired key) and 429 (rate limit reached). All errors

Start from a report

In the app, open Reports › Attribution, then the Share menu’s Copy as API request: the report on your screen as a curl request, with its goal, credit, period, comparison, and filters as parameters. It reads your API key from the LYLI_API_KEY environment variable, so a copied request never contains a key. A row you picked in the report isn’t a parameter, so the request returns the whole report.