TapCub is live — analytics, insights and live chat, free on one platform
Help center

How do I query my data with SQL?

Open the SQL tab in Behavior analysis and write one SELECT against four project-scoped views: v_events, v_sessions, v_persons and v_autocapture. Limits, the {filters} placeholder and two worked queries.

Product analytics2 min readLast updated Nov 4, 2026TapCub team

Still have a question?

Could not find it? A person reads every message, usually within a few hours on business days.

Chat with us

Short answer

In All-platform analytics › Behavior › Behavior analysis, open the SQL tab and write one SELECT against v_events, v_sessions, v_persons or v_autocapture, which are already scoped to the project and date range. Results return up to 50,000 rows with a 30-second timeout.

Short answer

Open All-platform analytics › Behavior › Behavior analysis and switch to the SQL tab. Write one SELECT (or WITH … SELECT) against the views v_events, v_sessions, v_persons or v_autocapture. They are already limited to the current project and the selected date range. Run with Command-Enter or Ctrl-Enter.

Use SQL for cross-tabs and one-off lists the built-in models do not give you. For a recurring ratio, save a custom metric instead.

The four views

ViewScopeUseful columns
v_eventsProject, selected datests, name, path, title, ref_channel, utm_source, utm_campaign, country, device_type, props, session_id, subject
v_sessionsProject, by session startid, started_at, entry_path, exit_path, pageviews, duration, channel, is_bounce, engaged, device_type, subject
v_personsProject, not cut by timeperson_id, first_seen, last_seen, identified_by, device_count, props
v_autocaptureProject, selected dateskind, path, selector, el_text, x, y, depth

subject is the person, visitor or account, depending on the identity chosen in the builder.

Two example queries

Sessions and engaged sessions by channel and device:

SELECT channel, device_type,
       COUNT(*) AS sessions,
       SUM(CASE WHEN engaged = 1 THEN 1 ELSE 0 END) AS engaged_sessions
FROM v_sessions
GROUP BY channel, device_type
ORDER BY sessions DESC

Entry pages of sessions that included a sign-up:

WITH signups AS (
  SELECT DISTINCT session_id FROM v_events WHERE name = 'signup'
)
SELECT s.entry_path, COUNT(*) AS sessions
FROM v_sessions s
JOIN signups g ON s.id = g.session_id
GROUP BY s.entry_path
ORDER BY sessions DESC
LIMIT 20

To apply the builder's global filters, put {filters} in a WHERE clause: WHERE {filters}. It becomes a constant true when there are no filters, and only works on columns the view has. Return rewritten SQL shows the statement that actually ran.

Limits

  • One SELECT or WITH statement. Comments, semicolons, backticks, writes and system tables are rejected, as are real table names.
  • At most 50,000 rows returned (the footer says when the result was cut), 30-second timeout, 20,000 characters of SQL.
  • No breakdown control and no compare period; segment comparison is rejected.
  • Members with hidden properties cannot run SQL.

Common errors

MessageFix
Must reference at least one viewQuery v_events, v_sessions, v_persons or v_autocapture
Only the four views can be queriedRemove database or table names; use the views
TimeoutNarrow the date range, aggregate earlier, add LIMIT

Need a file for someone else to download later? Use an export job; see export raw data.

Did this answer your question?

We use your answers to fix and expand this page.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics