Skip to content

API reference Events

API reference

Events

The API operations about events, each with its input, its output and an example.

The operations about events. Each one is a POST with a JSON object as its body: Making a request has the rules they share.

Custom event counts #

POST /api/v1/events.counts · Read

The custom events of one site in a period, by name: how often each fired, its share of all custom events, the visitors who fired it and whether a conversion goal counts it. Get the siteId from sites.list first. A custom event is one the website sends itself (a signup, a click); page views are not in this list. It pages by offset: limit rows (8 unless set, 100 at most) starting at offset, and totalRows is the number of names there are; offset plus limit may not be more than 1000 (400 otherwise). Rows are sorted by count, most first, unless sort and dir say otherwise; search keeps the names that contain the text. totalEvents and totalTypes cover the whole period whatever the search. Every filter applies. The comparison is not used. For the values of event properties call events.properties, and for the trend over time events.insights. Answers 402 workspace_locked while the workspace's dashboards are locked.

Needs a token with the Read permission. Answers 402 while the dashboards of the workspace are locked.

Input #

Field Type Required Description
siteId string required The site id, from sites.list.
range "today" | "yesterday" | "30m" | "12h" | "24h" | "week" | "7d" | "30d" | "60d" | "90d" | "mtd" | "ytd" | "12mo" | "all" | "custom" optional The period to report on: one of today, yesterday, 30m, 12h, 24h, week, 7d, 30d, 60d, 90d, mtd, ytd, 12mo, all. Left out, the workspace's default range is used (30d unless it was changed). For exact dates send from and to and leave range out (custom is accepted with them and means the same). A preset together with dates answers 400.
from string optional First day of a custom period, YYYY-MM-DD in the site's time zone. Send it together with to: one without the other answers 400, and so does a day that does not exist or a from after to. A day after today is read as today; window in the answer shows the period that was used.
to string optional Last day of a custom period, inclusive, YYYY-MM-DD in the site's time zone. Send it together with from.
compare "prev" | "week" | "month" | "quarter" | "year" | "custom" | "off" optional What the period is compared with: prev (the period just before, the default), week, month, quarter or year earlier, custom (cfrom and cto are then required), or off for no comparison. The range all never has a comparison.
cfrom string optional First day of a custom comparison period, YYYY-MM-DD. Required with compare set to custom, where a day that does not exist or a cfrom after cto answers 400.
cto string optional Last day of a custom comparison period, inclusive, YYYY-MM-DD. Required with compare set to custom.
filters object optional Narrow the numbers to matching traffic. An object such as { "country": "us", "path.has": "pricing" }. A plain key means "is"; a key ending in .not means "is not" and a key ending in .has means "contains". Filters are joined with AND. At most 10 keys, of which at most 3 may end in .has. Default: {}. The filter keys are listed under Filters.
limit integer, 1 to 100 optional Rows per page, 1 to 100. 8 when left out.
offset integer, 0 to 1000 optional Rows to skip, 0 to 1000. offset plus limit may not be more than 1000.
search string, 1 to 100 characters optional Keep only event names that contain this text, ignoring case. 1 to 100 characters.
sort "count" | "visitors" | "name" optional What to order the rows by: count (the default), visitors or name.
dir "asc" | "desc" optional asc or desc. Left out: desc, or asc when sorting by name.

Output #

Field Type Present Description
serverNow number always The clock the period was resolved with: the start of the next whole minute, milliseconds since 1970 UTC.
serverTime number always When the answer was built, milliseconds since 1970 UTC.
window object always The period the numbers cover: from and to in milliseconds since 1970 UTC (to is exclusive), the time zone, a label and the bucket size.
compare object | null always The comparison period in the same form, or null when there is none.
rawFrom number | null always The earliest time detailed data is kept from, or null when nothing was trimmed.
truncated boolean always True when a filtered answer could only cover the part of the period that still has detailed data.
totalEvents number always All custom events of the period with the filters applied, whatever the search.
totalTypes number always The number of distinct event names among them.
totalRows number always The number of names after the search. Page with limit and offset until offset reaches it; only the first 1,000 rows can be reached.
rows array of object always One row per event name: count is how often it fired, share its part of totalEvents (a fraction from 0 to 1), visitors the visitors who fired it, and isConversion whether an enabled conversion goal counts it.

Example #

curl -s -X POST https://clearsaga.com/api/v1/events.counts \
  -H "Authorization: Bearer $CLEARSAGA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"siteId":"site_abc123def456"}'

Run clearsaga help events counts for one flag per field.

Custom event trends #

POST /api/v1/events.insights · Read

Custom events of one site over time and which are growing: totals for the period and the period before, a chart of the top events per bucket, and a table of every event with its count, its count before and the change. Get the siteId from sites.list first. It always compares with the period just before, whatever compare, cfrom and cto say; the range all has no period before, so there previous and change are null. An event that fired before and not in this period is listed with count 0 and change -1. The table pages by offset: limit rows (50 unless set, 100 at most) starting at offset, and totalRows is the number of rows there are. It is sorted by growth (count minus the count before), largest first, unless sort and dir say otherwise. The chart has the top event names (5 unless top says otherwise) and, when there are more names than that, one last line named Other that sums the rest. Every filter applies. Answers 402 workspace_locked while the workspace's dashboards are locked.

Needs a token with the Read permission. Answers 402 while the dashboards of the workspace are locked.

Input #

Field Type Required Description
siteId string required The site id, from sites.list.
range "today" | "yesterday" | "30m" | "12h" | "24h" | "week" | "7d" | "30d" | "60d" | "90d" | "mtd" | "ytd" | "12mo" | "all" | "custom" optional The period to report on: one of today, yesterday, 30m, 12h, 24h, week, 7d, 30d, 60d, 90d, mtd, ytd, 12mo, all. Left out, the workspace's default range is used (30d unless it was changed). For exact dates send from and to and leave range out (custom is accepted with them and means the same). A preset together with dates answers 400.
from string optional First day of a custom period, YYYY-MM-DD in the site's time zone. Send it together with to: one without the other answers 400, and so does a day that does not exist or a from after to. A day after today is read as today; window in the answer shows the period that was used.
to string optional Last day of a custom period, inclusive, YYYY-MM-DD in the site's time zone. Send it together with from.
compare "prev" | "week" | "month" | "quarter" | "year" | "custom" | "off" optional Accepted and ignored: this report always compares with the period just before.
cfrom string optional Accepted and ignored: this report always compares with the period just before.
cto string optional Accepted and ignored: this report always compares with the period just before.
filters object optional Narrow the numbers to matching traffic. An object such as { "country": "us", "path.has": "pricing" }. A plain key means "is"; a key ending in .not means "is not" and a key ending in .has means "contains". Filters are joined with AND. At most 10 keys, of which at most 3 may end in .has. Default: {}. The filter keys are listed under Filters.
top integer, 1 to 20 optional How many event names the chart gets a line for, 1 to 20. 5 when left out.
limit integer, 1 to 100 optional Rows of the table per page, 1 to 100. 50 when left out.
offset integer, 0 to 1000 optional Rows to skip, 0 to 1000. offset plus limit may not be more than 1000.
sort "growth" | "count" | "previous" | "change" | "share" optional What to order the table by: growth (count minus the count before, the default), count, previous (the count before), change (the relative change) or share.
dir "asc" | "desc" optional asc or desc. desc when left out.

Output #

Field Type Present Description
serverNow number always The clock the period was resolved with: the start of the next whole minute, milliseconds since 1970 UTC.
serverTime number always When the answer was built, milliseconds since 1970 UTC.
window object always The period the numbers cover: from and to in milliseconds since 1970 UTC (to is exclusive), the time zone, a label and the bucket size.
compare object | null always The comparison period in the same form, or null when there is none.
rawFrom number | null always The earliest time detailed data is kept from, or null when nothing was trimmed.
truncated boolean always True when a filtered answer could only cover the part of the period that still has detailed data.
totals object always Custom events, distinct event names (types) and distinct visitors with an event in the period, and the same three for the period before in previous. previous is null for the range all, which has no period before.
buckets array of object always The buckets of the period, oldest first: start and end in milliseconds since 1970 UTC (end exclusive), partial true while the bucket is still running. The counts of series and the spark of each row line up with them by position.
series array of object always The chart: the top event names by count, each with its count per bucket. When the period has more names than top, one more line follows that sums all the others; it is named Other and is always the last line, so tell it apart by position, because a site can have an event of that name.
totalRows number always The number of rows of the table. Page with limit and offset until offset reaches it. It can be larger than totals.types, because events that stopped are listed too.
rows array of object always One row per event name that occurs in the period or in the period before. count is how often it fired, previous the same for the period before, and change the difference as a fraction of previous (0.5 means up 50 percent); change is null when the event is new or there is no period before. An event that fired before and not now has count 0 and change -1. share is its part of all custom events of the period, visitors the visitors who fired it, spark its count per bucket, and isConversion whether an enabled conversion goal counts it.

Example #

curl -s -X POST https://clearsaga.com/api/v1/events.insights \
  -H "Authorization: Bearer $CLEARSAGA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"siteId":"site_abc123def456"}'

Run clearsaga help events insights for one flag per field.

Activity log #

POST /api/v1/events.log · Read

The single hits of one site in a period, newest first: page views, custom events and pages that were not found, each with its time, path, referring site and country. Get the siteId from sites.list first. feed chooses what is listed: all (everything), views (page views), events (custom events) or properties (custom events that were sent with properties). It pages by cursor: the answer holds limit rows (50 unless set, 100 at most) and nextCursor; send that as cursor for the next, older page, until it is null. A cursor this list did not issue answers 400 invalid_cursor. There is no total. The feeds all and views ignore the event and prop filters; every other filter applies. The comparison is not used. No row names a visitor: there is no visitor-level data. For totals call events.counts or overview.kpis, not this. Answers 402 workspace_locked while the workspace's dashboards are locked.

Needs a token with the Read permission. Answers 402 while the dashboards of the workspace are locked.

Input #

Field Type Required Description
siteId string required The site id, from sites.list.
range "today" | "yesterday" | "30m" | "12h" | "24h" | "week" | "7d" | "30d" | "60d" | "90d" | "mtd" | "ytd" | "12mo" | "all" | "custom" optional The period to report on: one of today, yesterday, 30m, 12h, 24h, week, 7d, 30d, 60d, 90d, mtd, ytd, 12mo, all. Left out, the workspace's default range is used (30d unless it was changed). For exact dates send from and to and leave range out (custom is accepted with them and means the same). A preset together with dates answers 400.
from string optional First day of a custom period, YYYY-MM-DD in the site's time zone. Send it together with to: one without the other answers 400, and so does a day that does not exist or a from after to. A day after today is read as today; window in the answer shows the period that was used.
to string optional Last day of a custom period, inclusive, YYYY-MM-DD in the site's time zone. Send it together with from.
compare "prev" | "week" | "month" | "quarter" | "year" | "custom" | "off" optional What the period is compared with: prev (the period just before, the default), week, month, quarter or year earlier, custom (cfrom and cto are then required), or off for no comparison. The range all never has a comparison.
cfrom string optional First day of a custom comparison period, YYYY-MM-DD. Required with compare set to custom, where a day that does not exist or a cfrom after cto answers 400.
cto string optional Last day of a custom comparison period, inclusive, YYYY-MM-DD. Required with compare set to custom.
filters object optional Narrow the numbers to matching traffic. An object such as { "country": "us", "path.has": "pricing" }. A plain key means "is"; a key ending in .not means "is not" and a key ending in .has means "contains". Filters are joined with AND. At most 10 keys, of which at most 3 may end in .has. Default: {}. The filter keys are listed under Filters.
feed "all" | "views" | "events" | "properties" required What to list: all, views (page views only), events (custom events only) or properties (custom events that carry properties).
cursor string, at most 200 characters optional Where to continue: the nextCursor of the page before. Leave it out for the newest rows.
limit integer, 1 to 100 optional Rows per page, 1 to 100. 50 when left out.

Output #

Field Type Present Description
serverNow number always The clock the period was resolved with: the start of the next whole minute, milliseconds since 1970 UTC.
serverTime number always When the answer was built, milliseconds since 1970 UTC.
window object always The period the numbers cover: from and to in milliseconds since 1970 UTC (to is exclusive), the time zone, a label and the bucket size.
compare object | null always The comparison period in the same form, or null when there is none.
rawFrom number | null always The earliest time detailed data is kept from, or null when nothing was trimmed.
truncated boolean always True when a filtered answer could only cover the part of the period that still has detailed data.
rows array of object always One row per recorded hit, newest first. ts is its time in milliseconds since 1970 UTC and kind is pageview, custom (a custom event) or 404 (a page that was not found). name is the event name of a custom event, else null. path is the page it happened on, referrer the referring host of the visit and country its two-letter code, both null when unknown. The code is in upper case (US), while the country filter and the keys of overview.breakdown take it in lower case (us). props holds the properties a custom event was sent with, and from the page that linked to a page that was not found. A row names no visitor.
nextCursor string | null always Send this as cursor to get the next, older page. Null on the last page.

Example #

curl -s -X POST https://clearsaga.com/api/v1/events.log \
  -H "Authorization: Bearer $CLEARSAGA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"siteId":"site_abc123def456","feed":"all"}'

Run clearsaga help events log for one flag per field.

Custom event names #

POST /api/v1/events.names · Read

The names of the custom events one site recorded in a period, each with how often it fired, most frequent first. The whole list comes at once, 500 names at most; there is no paging. Get the siteId from sites.list first. Use it to learn which names the event filter, a funnel step of type event or an event goal can take. The event and prop filters are ignored here, so the list is not narrowed by the name it is meant to help choose; every other filter applies. The comparison is not used. Answers 402 workspace_locked while the workspace's dashboards are locked.

Needs a token with the Read permission. Answers 402 while the dashboards of the workspace are locked.

Input #

Field Type Required Description
siteId string required The site id, from sites.list.
range "today" | "yesterday" | "30m" | "12h" | "24h" | "week" | "7d" | "30d" | "60d" | "90d" | "mtd" | "ytd" | "12mo" | "all" | "custom" optional The period to report on: one of today, yesterday, 30m, 12h, 24h, week, 7d, 30d, 60d, 90d, mtd, ytd, 12mo, all. Left out, the workspace's default range is used (30d unless it was changed). For exact dates send from and to and leave range out (custom is accepted with them and means the same). A preset together with dates answers 400.
from string optional First day of a custom period, YYYY-MM-DD in the site's time zone. Send it together with to: one without the other answers 400, and so does a day that does not exist or a from after to. A day after today is read as today; window in the answer shows the period that was used.
to string optional Last day of a custom period, inclusive, YYYY-MM-DD in the site's time zone. Send it together with from.
compare "prev" | "week" | "month" | "quarter" | "year" | "custom" | "off" optional What the period is compared with: prev (the period just before, the default), week, month, quarter or year earlier, custom (cfrom and cto are then required), or off for no comparison. The range all never has a comparison.
cfrom string optional First day of a custom comparison period, YYYY-MM-DD. Required with compare set to custom, where a day that does not exist or a cfrom after cto answers 400.
cto string optional Last day of a custom comparison period, inclusive, YYYY-MM-DD. Required with compare set to custom.
filters object optional Narrow the numbers to matching traffic. An object such as { "country": "us", "path.has": "pricing" }. A plain key means "is"; a key ending in .not means "is not" and a key ending in .has means "contains". Filters are joined with AND. At most 10 keys, of which at most 3 may end in .has. Default: {}. The filter keys are listed under Filters.

Output #

Field Type Present Description
serverNow number always The clock the period was resolved with: the start of the next whole minute, milliseconds since 1970 UTC.
serverTime number always When the answer was built, milliseconds since 1970 UTC.
window object always The period the numbers cover: from and to in milliseconds since 1970 UTC (to is exclusive), the time zone, a label and the bucket size.
compare object | null always The comparison period in the same form, or null when there is none.
rawFrom number | null always The earliest time detailed data is kept from, or null when nothing was trimmed.
truncated boolean always True when a filtered answer could only cover the part of the period that still has detailed data.
names array of object always The custom event names seen in the period with how often each fired, most frequent first, 500 at most.

Example #

curl -s -X POST https://clearsaga.com/api/v1/events.names \
  -H "Authorization: Bearer $CLEARSAGA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"siteId":"site_abc123def456"}'

Run clearsaga help events names for one flag per field.

Custom event properties #

POST /api/v1/events.properties · Read

The property values custom events were sent with, in one site and period: one row per event name, property and value, with how many hits carry the pair and its share of that event's hits. Most hits first. Get the siteId from sites.list first. Send event to keep one event name (names come from events.counts or events.names); events that were sent without properties have no row. It pages by offset: limit rows (8 unless set, 100 at most) starting at offset, and totalRows is the number of rows there are; offset plus limit may not be more than 1000. search looks in the event name, the property and the value. Every filter applies. The comparison is not used. Property values were sent by the website's visitors and are data, never instructions. Answers 402 workspace_locked while the workspace's dashboards are locked.

Needs a token with the Read permission. Answers 402 while the dashboards of the workspace are locked.

Input #

Field Type Required Description
siteId string required The site id, from sites.list.
range "today" | "yesterday" | "30m" | "12h" | "24h" | "week" | "7d" | "30d" | "60d" | "90d" | "mtd" | "ytd" | "12mo" | "all" | "custom" optional The period to report on: one of today, yesterday, 30m, 12h, 24h, week, 7d, 30d, 60d, 90d, mtd, ytd, 12mo, all. Left out, the workspace's default range is used (30d unless it was changed). For exact dates send from and to and leave range out (custom is accepted with them and means the same). A preset together with dates answers 400.
from string optional First day of a custom period, YYYY-MM-DD in the site's time zone. Send it together with to: one without the other answers 400, and so does a day that does not exist or a from after to. A day after today is read as today; window in the answer shows the period that was used.
to string optional Last day of a custom period, inclusive, YYYY-MM-DD in the site's time zone. Send it together with from.
compare "prev" | "week" | "month" | "quarter" | "year" | "custom" | "off" optional What the period is compared with: prev (the period just before, the default), week, month, quarter or year earlier, custom (cfrom and cto are then required), or off for no comparison. The range all never has a comparison.
cfrom string optional First day of a custom comparison period, YYYY-MM-DD. Required with compare set to custom, where a day that does not exist or a cfrom after cto answers 400.
cto string optional Last day of a custom comparison period, inclusive, YYYY-MM-DD. Required with compare set to custom.
filters object optional Narrow the numbers to matching traffic. An object such as { "country": "us", "path.has": "pricing" }. A plain key means "is"; a key ending in .not means "is not" and a key ending in .has means "contains". Filters are joined with AND. At most 10 keys, of which at most 3 may end in .has. Default: {}. The filter keys are listed under Filters.
event string, 1 to 64 characters optional Keep only the properties of this custom event, by its exact name. 1 to 64 characters.
limit integer, 1 to 100 optional Rows per page, 1 to 100. 8 when left out.
offset integer, 0 to 1000 optional Rows to skip, 0 to 1000. offset plus limit may not be more than 1000.
search string, 1 to 100 characters optional Keep only rows whose event name, property or value contains this text, ignoring case. 1 to 100 characters.

Output #

Field Type Present Description
serverNow number always The clock the period was resolved with: the start of the next whole minute, milliseconds since 1970 UTC.
serverTime number always When the answer was built, milliseconds since 1970 UTC.
window object always The period the numbers cover: from and to in milliseconds since 1970 UTC (to is exclusive), the time zone, a label and the bucket size.
compare object | null always The comparison period in the same form, or null when there is none.
rawFrom number | null always The earliest time detailed data is kept from, or null when nothing was trimmed.
truncated boolean always True when a filtered answer could only cover the part of the period that still has detailed data.
totalRows number always The number of rows after the search and the event choice. Page with limit and offset until offset reaches it; only the first 1,000 rows can be reached.
rows array of object always One row per event name, property and value, most hits first: count is the number of hits that carry the pair and shareOfEvent its part of all hits of that event, a fraction from 0 to 1.

Example #

curl -s -X POST https://clearsaga.com/api/v1/events.properties \
  -H "Authorization: Bearer $CLEARSAGA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"siteId":"site_abc123def456"}'

Run clearsaga help events properties for one flag per field.