For the complete documentation index, see llms.txt. This page is also available as Markdown.

How do analytics and reports work?

At the core of every analytics process are events. An event is usually some kind of user action: a bot launch, opening a website page, clicking a button, a purchase, a user churn, sending a message, etc.

Each event has several parameters, the main ones being:

  1. date - the date and time the event occurred

  2. user_id - the user who performed the event. Can be 0 - such events are called anonymous

  3. event_id/event_name - the name of the event that occurred

  4. category_id/category_name - the event category, for additional categorization of events

  5. value_int - a numeric value, this can be a sale amount or any other numeric value. For monetary events, the value is stored in the smallest unit of the currency (e.g. kopecks for RUB) — exactly as it was sent via value_num/unit, with no conversion applied

  6. unit - the unit of measurement, for example usd

  7. value_amount - a computed field available only in reports (not a stored column): it converts value_int back into normal units (rubles rather than kopecks) and converts it at the current exchange rate into the currency set in your profile. Use this instead of value_int whenever you're summing money — see Trends for details

  8. etc...

All events are stored as one large table, which can be queried to build various reports.

To build truly useful reports it is critically important to collect all the necessary events; it's impossible to build a report on the number of sales if we physically don't have sales events.

How do you collect events?

When you connect graspil, you automatically get access to a fairly wide set of events. However, every product is unique and requires individual configuration. For this, the following tools are available to you:

  1. API - the API lets you pass events even in the most complex cases

  2. Triggers - you can set conditions under which an event will be created. For example, your bot sends a message after a sale with the text "Thank you for your purchase"; you can create a trigger that looks for the phrase "Thank you for your purchase" in messages and creates an event

  3. Automation - when creating automations you can also create events.

  4. Sending events from a mini app - you can create events on specific clicks or actions.

  5. Following outbound links - if a user follows a link from a bot or channel, there is a way to create an event on that click.

Which events are created automatically in graspil?

When you connect a resource, a large set of standard events becomes available automatically — bot launches and blocks, messages, payments, mini app actions, broadcasts, and more. See the full list with names and explanations on the Event reference page.

Last updated