Documentation menuAnalyze: Custom dashboards and SQL

Analyze

Custom dashboards and SQL in Loogika

The built-in reports answer the common questions. For the rest, Loogika has a Query page where you run SQL against your events, and Dashboards where you save the results as charts.

Last updated .

How do you run a query?

Open Query in the site sidebar. Write SQL, or describe what you want in the box labelled "What do you want to query?" and click Generate.

Click Run to get the result as a table. Download results exports it as CSV or JSON. The Query page draws no charts, so use a dashboard for those.

Generate works on the query that is already there, so you can refine it with a follow-up.

Which data can you query?

Queries are read-only and use ClickHouse SQL. There is one table, scoped_events, which holds every event for the current site.

SELECT pathname, count() AS views
FROM scoped_events
WHERE type = 'pageview'
  AND timestamp >= now() - INTERVAL 7 DAY
GROUP BY pathname
ORDER BY views DESC
LIMIT 20

Statements that write data, change settings or read other tables are rejected.

The most used columns:

ColumnContent
timestampWhen the event arrived, in UTC
typepageview, custom_event, performance, outbound, error, button_click, copy, form_submit or input_change
event_nameThe name of a custom event or an error
propsThe event properties, as JSON
session_id, user_idThe anonymous session and visitor
identified_user_idYour own user ID. Empty when the visitor is not identified
hostname, pathname, querystring, page_titleThe page
url_parametersThe query parameters as a map, such as UTM values
referrer, channelWhere the visit came from
country, region, city, lat, lon, timezoneLocation, found from the IP address
browser, browser_version, operating_system, operating_system_versionBrowser and system
device_type, screen_width, screen_height, languageDevice
lcp, cls, inp, fcp, ttfbWeb Vitals, on performance events only
tagThe value of data-tag
ipThe IP address. Filled only when Track IP Address is on
import_idSet on imported events. Empty on tracked events
asn, asn_org, is_datacenter_asnThe visitor's network
site_idThe numeric site ID

What are the limits?

LimitValue
Rows in a result1,000
Run time10 seconds
Queries60 per minute
Generated queries20 per minute
Cards on a dashboard20

The Query page does not follow the date selector. Add your own condition on timestamp, or the query reads all your data.

How do you build a dashboard?

Open Dashboards in the site sidebar and create one. Add a card from the examples or start with an empty card.

A card has a title, a query and a chart type. You choose which columns to plot and how to format the values: number, percent, duration or bytes.

Chart types
Line, Area, Bar, Bar list, Donut, Stat, Table, Map, Calendar

Drag cards to move them and pull the corner to resize. Save with Ctrl+S, or ⌘S on a Mac.

How do cards follow the date selector?

On a dashboard, scoped_events only holds events from the period in the date selector. You do not filter on dates yourself.

Two placeholders keep the charts in step with the controls:

PlaceholderReplaced with
{{bucket}}The interval from the bucket selector, such as hour, day or week
{{tz}}Your time zone, so a daily bucket matches a calendar day

Who can use queries and dashboards?

Every member who can open the site can run queries and open dashboards. Any of them can also create, edit and delete dashboards on that site.

Query and Dashboards are hidden on public dashboards and private links.