Database querying

In some cases it can be useful to query the userTrack database directly. This page explains the database structure and how the data is stored in it.

Database structure

NOTE: This was the database structure for version 3.5.0. A newer userTrack version might include new tables.

Here is a diagram created by the PHPMyAdmin->Designer of an existing userTrack database:

Remarks

  • ust_clients - Stores unique sessions/visits. An unique user can have multiple entries. The ip can be used to link all sessions from the user.

  • ust_clientpage - Stores unique pageviews. Each session has multiple pageviews.

  • ust_records/ust_partials - Store the record playback information for a specific pageview.

  • ust_movements/ust_clicks - Heatmap data, stored per pageview.

  • ust_client_tag - Session level tag/label/event data.

  • ust_client_event - Events stored linked to a specific pageview, session and user.

  • ust_ab - Stores AB tests

  • ust_users (internal) - Stores list of userTrack dashboard users

  • ust_access (internal) - Stores which domain data can be accessed by which users

For improved performance, there are multiple indexes already created. Those indexes are specifically created for the queries ran for the userTrack dashboard, but they should also lead to very fast query performance in most cases.

Examples

You can find many example queries in the PHP source code of userTrack. Usually each PHP file only runs a single query.

Basic query

SELECT * FROM `ust_clients` WHERE `domain`="domain.com"