viakite
Dashboard

API/Events/Send events

Send events

POST/v1/events

Receives page views, custom events, engagement and identify events, and the heatmap script's clicks and scroll depths, one or a list of up to 100 (500 KB at most). Clicks and scroll depths are stored apart from events (for Analytics → Heatmaps, F80–F82) and are never counted as events in reports. Served on a region's events host, https://us.e.vk.viabio.me/v1/events.

Through a proxy on the customer's own domain, the same endpoint answers at /va/e. The proxy sets X-Forwarded-For to the visitor's address and may send the visitor's location in X-Viakite-Country (two letters), X-Viakite-Region and X-Viakite-City (URL-encoded), which come before the edge's own.

From a browser (the script and @viakite/sdk): no Authorization header; every event names the project's public key (pk_…) in project. The visitor comes from the request: its address and user agent (hashed, then dropped), and the edge's location.

From a server: send a secret key (Authorization: Bearer sk_…) with the analytics.send scope, and name the project by its id (prj_…) in every event's project. The server's own user agent is never counted as a bot and its location is not used. Pass the visitor's ip and user_agent to tell visitors apart, to read the device and to apply bot rules and excluded addresses; without them, an event with a user_id counts that user as one visitor for the day.

The answer is always 202 once the key is good, with how many events were stored and how many dropped (bots, excluded visitors, hostnames not allowed, invalid events, or a plan's limit). An event with an id already received is stored once, so retrying a request is safe.

Secret keyus.e.vk.viabio.me

Body

IngestEventobject
Unknown fields are ignored.
Show 25 fields
typestringrequired
pageview needs url; event needs name; engagement needs pageview_id; identify needs user_id; click and scroll (the heatmap script) need url, pageview_id and viewport, and a click needs x (0 to 1) and y (0 or more).
pagevieweventengagementidentifyclickscroll
idstringup to 64 chars
A unique id the sender makes (a ULID). A second event with the same id is not stored. Made by the server when missing.
projectstring
The project's public key (pk_…) from a browser, or its id (prj_…) with a secret key.
urlstring
The page's full address. Query parameters not on the allow-list are removed.
referrerstring
The page's referrer.
titlestring
The page's title, when the project sends titles.
screeninteger[]2–2 items
The screen's width and height in pixels.
languagestring
The browser's language, such as en-IN.
tsinteger
When the event happened, in Unix milliseconds on the sender's clock.
sentinteger
When the request was sent, in Unix milliseconds on the same clock. With ts, it corrects the sender's clock (up to 24 hours back).
namestring
The custom event's name (event), cut to 120 characters.
propsobject
The event's properties, up to 20 flat values. revenue and currency record money.
user_idstring
Your own id for the signed-in user. Dropped when it looks like an e-mail address or phone number.
traitsobject
Facts about the user (identify), with the same limits as props.
pageview_idstring
The page view's id an engagement event belongs to.
engaged_msinteger
Engaged time on the page in milliseconds, capped at 30 minutes.
scrollinteger
The furthest scroll in percent; kept as 25, 50, 75 or 100 on engagement, and to the percent (0 to 100) on scroll.
xnumber
A click's horizontal position as a share of the page's width, 0 to 1.
yinteger
A click's vertical position in pixels from the top of the page.
viewportinteger
The viewport's width in pixels (click, scroll): under 768 is mobile, under 1,024 tablet, desktop from there.
page_heightinteger
The page's height in pixels (click, scroll).
selectorstringup to 255 chars
A click's target as a short CSS selector (tag, id, classes); never its text.
not_foundboolean
The page view is of a page that wasn't found.
ipstring
The visitor's IP address, read only with a secret key. Hashed into the visitor id and checked against excluded ranges, then dropped; never stored.
user_agentstringup to 512 chars
The visitor's user agent, read only with a secret key. Gives the device, browser and system and the bot check, then is dropped.
option 2IngestEvent[]
Show 25 fields
typestringrequired
pageview needs url; event needs name; engagement needs pageview_id; identify needs user_id; click and scroll (the heatmap script) need url, pageview_id and viewport, and a click needs x (0 to 1) and y (0 or more).
pagevieweventengagementidentifyclickscroll
idstringup to 64 chars
A unique id the sender makes (a ULID). A second event with the same id is not stored. Made by the server when missing.
projectstring
The project's public key (pk_…) from a browser, or its id (prj_…) with a secret key.
urlstring
The page's full address. Query parameters not on the allow-list are removed.
referrerstring
The page's referrer.
titlestring
The page's title, when the project sends titles.
screeninteger[]2–2 items
The screen's width and height in pixels.
languagestring
The browser's language, such as en-IN.
tsinteger
When the event happened, in Unix milliseconds on the sender's clock.
sentinteger
When the request was sent, in Unix milliseconds on the same clock. With ts, it corrects the sender's clock (up to 24 hours back).
namestring
The custom event's name (event), cut to 120 characters.
propsobject
The event's properties, up to 20 flat values. revenue and currency record money.
user_idstring
Your own id for the signed-in user. Dropped when it looks like an e-mail address or phone number.
traitsobject
Facts about the user (identify), with the same limits as props.
pageview_idstring
The page view's id an engagement event belongs to.
engaged_msinteger
Engaged time on the page in milliseconds, capped at 30 minutes.
scrollinteger
The furthest scroll in percent; kept as 25, 50, 75 or 100 on engagement, and to the percent (0 to 100) on scroll.
xnumber
A click's horizontal position as a share of the page's width, 0 to 1.
yinteger
A click's vertical position in pixels from the top of the page.
viewportinteger
The viewport's width in pixels (click, scroll): under 768 is mobile, under 1,024 tablet, desktop from there.
page_heightinteger
The page's height in pixels (click, scroll).
selectorstringup to 255 chars
A click's target as a short CSS selector (tag, id, classes); never its text.
not_foundboolean
The page view is of a page that wasn't found.
ipstring
The visitor's IP address, read only with a secret key. Hashed into the visitor id and checked against excluded ranges, then dropped; never stored.
user_agentstringup to 512 chars
The visitor's user agent, read only with a secret key. Gives the device, browser and system and the bot check, then is dropped.

Responses

Received; the counts of stored and dropped events.

acceptedintegerrequired
Events stored.
droppedintegerrequired
Events not stored: bots, excluded, hostnames not allowed, invalid, over a plan's limit, or test events past the 100,000 a month.
Example response
1{
2 "accepted": 1,
3 "dropped": 1
4}

Errors

Every error has the same shape: error.code, a message for people and details.

StatusCode
401missing_key
401unauthorized
404not_found
403forbidden
422missing_project
422mixed_projects
413too_many_events
422validation_error
400bad_request