Attribution
BetaWhere 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.
Parameters
app.lyli.io/sites/<id>. /sites lists the ones your key can read./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.last or first: which visit gets the credit. last if left out. How credit workstoday, yesterday, 7d, 30d, 90d, 52w, or a range of days or hours. The last 30 days if left out. Periodsprevious, month, or year. Adds compared to the response.America/New_York. The site’s own if left out.country=SE. They combine. FiltersRequest
An example site’s Subscription goal, the custom event subscription_started, over the last 30 days, each visitor credited to their first visit.
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// Node 18 or later, on your server
const params = new URLSearchParams({
goal: "subscription_started",
credit: "first",
period: "30d",
timezone: "Europe/Stockholm",
});
const res = await fetch(`https://app.lyli.io/api/v1/sites/s_k3m9x2p7qa/attribution?${params}`, {
headers: { Authorization: `Bearer ${process.env.LYLI_API_KEY}` },
});
if (!res.ok) throw new Error(`Lyli API: ${res.status}`);
const { totals, rows } = await res.json();import os
import requests
res = requests.get(
"https://app.lyli.io/api/v1/sites/s_k3m9x2p7qa/attribution",
params={
"goal": "subscription_started",
"credit": "first",
"period": "30d",
"timezone": "Europe/Stockholm",
},
headers={"Authorization": f"Bearer {os.environ['LYLI_API_KEY']}"},
timeout=10,
)
res.raise_for_status()
rows = res.json()["rows"]Response
{
"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.
timezone, and its step, interval, as in the Overview.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.first or last, as asked.null when no completion sent an amount, in the period or the one compared, which is always so for a page.channel, source, campaign, medium, and entry. Each visitor is credited to one value of each field.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.totals. null when totals.revenue is.null, 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:
- On a cookieless site, a visitor’s code lasts a day, so
firstmeans their first visit that day, and someone who comes on two days counts as two visitors. For visitors the site recognizes (Recognize returning visitors, withdata-rememberon the tag once they agree),firstcan 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
against=month for a period over 5 weeks; or no goal for a site with no goals yet.A site with no goals yet, asked without goal:
{
"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.