Reference
Journeys
A journey is one visit by one browser: the pages it opened, in order, with the seconds spent on each. The browser keeps it, announces it over presence, and reports it to WordPress, where a site may keep it. Introduced in WordSocket 0.30, stored since 0.31.
1. The journey format
A journey is a string of kind:id:s steps joined by >, oldest first.
home:0:12>product:42:31>away:0:95>product:42:8>cart:0:20
| Part | Meaning |
|---|---|
| kind |
What the page is, [a-z_]+: a post type for a single post or page
(post, page, product), category,
tag or a taxonomy's name for a term archive, <type>_archive
for a post type's archive (post_archive is the blog index), or
home, search, archive (a date or author archive),
other, admin. An extension renames kinds through the
wpsignal_page_step filter.
|
| id | The post or term id, 0 when the kind has none. Up to 12 digits. |
| s | The time spent on the step in whole seconds. Up to 6 digits. |
| away:0:s | The tab was hidden for that long. |
- Ids only: a journey never holds a URL, a slug, a title or a search term.
- At most 50 steps (older steps drop off the front) and 4000 bytes.
- One journey is one visit. It lives in the tab's
sessionStorageand a new one, with a new id, starts when the visitor arrives more than 30 minutes after the last arrival. - PHP validates a journey with
WPSignal\Presence::JOURNEY_PATTERN.
2. Tracking in the browser
WPS.presence.track( channel, options ) keeps the journey, enters presence with it
and sends the reports. With History on and no extension tracking, WordSocket starts a
presence-free tracker of its own. The API is on the
JS API page.
Journeys follow the client script. By default WordSocket loads it for logged-in users only;
return true from the wpsignal_allow_client filter to load it for
every visitor. Until a plugin reserves a namespace, a visitor's token may read and write every channel of the site, so reserve one before opening the client to guests.
3. Visit and leave reports
The tracker reports to two public routes on the site, POST /wp-json/wpsignal/v1/visit
and POST /wp-json/wpsignal/v1/leave. A visit is written on a change of state, not
on every page: a journey's first step, a page whose kind an extension named through
wpsignal_journey_write_kinds, the tab going hidden, an explicit
tracker.report(), and otherwise once 60 seconds after the last write while the
page is visible. A leave is sent as the tab closes or goes elsewhere.
| Field | Type | Description |
|---|---|---|
| v | string, required | The visitor id, a UUID. |
| n | string, required | The journey id, a UUID. |
| journey | string | The journey so far, in the format above. |
| data | object | The tracker's state: at most 20 fields, scalar values only, strings cut at 200 bytes. |
| ago | integer | Whole seconds since the report was true, 0 for one sent live, 30 days at most. A journey held in the browser after a crash or a lost connection is sent later with its age here. |
Both answer { "ok": true } with Cache-Control: no-store. A visit
also carries whatever plugins add through the wpsignal_visitor_visit_response
filter, each under one key of its own, which the browser reads with
tracker.onVisit(). Send the X-WP-Nonce header for a logged-in visitor;
without it the report counts as a guest's.
Each report reaches PHP on wpsignal_visitor_visit or
wpsignal_visitor_leave:
add_action( 'wpsignal_visitor_visit', function ( array $report ) {
// array(
// 'visitor' => '0b1f...', the visitor id
// 'journey_id' => '7c2e...', the journey id
// 'journey' => 'home:0:12>product:42:0',
// 'steps' => 2,
// 'user_id' => 0, the logged-in user, 0 for a guest
// 'data' => array( 'cart' => 'abc123' ),
// 'leaving' => false,
// 'ago' => 0,
// )
} );
- Apply reports by
steps, never by arrival: the leave of one page and the visit of the next can race. - A leave is best effort. A killed browser sends none, and relay presence (
wps.presence) is the live truth about who is here. - A leave with
agoabove 0 is history catching up, not a visitor leaving now. - The ids are the browser's word. Never key a limit or a permission on them.
4. History
With History on (the Journeys card on the Settings tab, off by default), WordSocket stores every
visit, leave and moment firing in the site's own database, one row per journey in
{prefix}wpsignal_journeys. Nothing is stored on WPSignal's servers.
- Retention is 3 months by default, 1 to 12. A daily prune deletes what is older.
- A journey's
outcomeisopen,left(a leave arrived),incomplete(nobody saw it end: the visitor started another journey after the 30 minute gap, or the daily prune found it unreported for an hour), or one an extension ends it with. - A row changes only for reports from the visitor it was created under that are at least as far along, and a visitor id starts at most 30 rows an hour (
wpsignal_journeys_per_hour). - A logged-in visit carries the user id, and WordPress's privacy exporter and eraser cover that user's rows.
- Turning History off stops the writing. What was kept stays until the retention or a purge deletes it.
- The Journeys tab draws the last 28 days and offers a CSV or JSON download. The History switch and the retention are also fields of POST /settings.
5. Adding your own facts
Journeys are WordSocket's; an extension adds what it knows. It names what a visitor carries
(a ref, up to 32 characters of [A-Za-z0-9_-], such as a cart id), what that
is worth, and how a journey can end. The methods are on
WPS::journeys().
use WPSignal\WPS;
// Name the outcome and the ref, with the trends the Journeys tab draws for them.
add_action( 'init', function () {
WPS::journeys()->outcome( 'booked', array(
'label' => 'Booked',
'color' => '#008300',
'series' => 'Bookings a day',
) );
WPS::journeys()->ref( array(
'label' => 'Enquiry',
'left_series' => 'Enquiries left behind a day',
) );
} );
// Each visit or leave: say what this visitor carries, read from your own session.
// $report is the browser's word, so never take the ref from it.
add_filter( 'wpsignal_journey_record', function ( array $record, array $report ) {
$enquiry = my_enquiry_for_session();
if ( '' !== $enquiry ) {
$record['ref'] = $enquiry;
$record['value'] = my_enquiry_total( $enquiry );
$record['data'] = array( 'rooms' => my_enquiry_rooms( $enquiry ) );
}
return $record;
}, 10, 2 );
// The enquiry became a booking: end its open journeys and credit the moments that fired.
add_action( 'my_booking_confirmed', function ( string $enquiry, int $booking_id, float $total ) {
WPS::journeys()->end_by_ref( $enquiry, 'booked', $total, array( 'booking' => $booking_id ) );
WPS::journeys()->credit( $enquiry, $booking_id, $total );
}, 10, 3 );
// Hand the browser its own state in the visit request the page already makes.
// Resolve it from the request's session, never from $report['visitor'], which the caller chooses.
add_filter( 'wpsignal_visitor_visit_response', function ( array $answer, array $report ) {
$answer['my_plugin'] = array( 'enquiry' => my_enquiry_for_session() );
return $answer;
}, 10, 2 );
-
datais stored as JSON of at most 4000 bytes and kept until a later report's record replaces it. -
end_by_ref()ends the ref'sopenjourneys only, and does nothing while History is off. A journey an extension ended keeps its ref, outcome, value and data against later reports, and the visit route answersjourney: { ended: true }for it, on which the tracker begins a new journey with the next page the visitor opens. -
credit()credits the order to the ref's journeys in which a moment fired within the window (7 days by default), once per journey. -
erase_refs()deletes the journeys carrying the given refs, for your own privacy eraser. - Other filters:
wpsignal_page_step(name your own page kinds),wpsignal_kind_codes(a short code a kind is stored under),wpsignal_journeys_currency,wpsignal_journey_context(what a stored journey offers a moment's replay). All are on the PHP API page.
6. REST routes
All under /wp-json/wpsignal/v1, all for users with manage_options.
GET /journeys
The stored journeys a moment is replayed over, newest first. days (1 to 90,
default 28) and limit (1 to 1000, default 1000).
{
"enabled": true,
"currency": "USD",
"journeys": [
{
"journey": "home:0:12>product:42:31>cart:0:20",
"started_at": "2026-11-02T14:03:11+00:00",
"outcome": "left",
"value": 59.0,
"has_ref": true,
"firings": [
{ "rule": "a1b2c3d4", "action": "show", "step": 2, "s": 15, "kind": "fired", "at": "2026-11-02 14:04:09" }
],
"context": {}
}
]
}
DELETE /journeys
Deletes stored journeys and answers { "deleted": 1234 }. Optional
from and to are days on the site's clock as YYYY-MM-DD,
both inclusive, and limit the delete to journeys started in those days; with neither, every
journey is deleted. from after to is
400 wpsignal_invalid_range. There is no undo.
GET /journeys/visuals
The Journeys tab's figures over the last 28 days on the site's clock, kept for 60 seconds;
fresh=1 computes them again.
| Field | Description |
|---|---|
| days | One entry per day: date, visits, left_ref (left while carrying a ref) and counts by outcome. |
| hours | 7 weekdays by 24 hours: visits, minutes on the site, and counts by outcome. |
| listed, total | How many of the newest journeys the minutes were read from (1,000 at most), and how many journeys the window holds. |
| months | [{ month: "YYYY-MM", count }], newest first, every month within the retention that holds a journey. |
| storage | { bytes, rows }: the table's size on disk and the journeys within the retention. |
| outcomes, ref, kinds, currency | The registered outcomes, the ref's labels, the page kinds with their labels, and the journeys currency. |
| since, timezone, week_start | Where the window starts, the site's timezone, and the first day of its week. |
GET /journeys/visuals/journeys
One month's journeys, 1,000 to a page, newest first. month
(YYYY-MM, on the site's clock) and page (from 1) are required; a
month that is not one is a 400. Answers
{ journeys: [{ journey, started_at, outcome, has_ref, value }] }.
7. The journey record
The download, the CLI's journeys list and the
wordsocket/list-journeys ability share
one listing, WPSignal\Journeys::query( $args ), and one record shape.
| Field | Type | Description |
|---|---|---|
| journey_id | string | One visit by one browser, a UUID. |
| visitor | string | The browser, a UUID; its visits share this id. |
| user_id | integer | The WordPress user when logged in, 0 for a guest. |
| ref | string | What the visitor carried, as an extension names it (ShopSocket: the cart id); empty when nothing. |
| outcome | string | open (still going), left, incomplete (never heard ending), or an outcome an extension ends journeys with (ShopSocket: converted). |
| value | number or null | The value an extension put on the journey, in the site’s journeys currency. |
| started_at | string | When the visit began, UTC, RFC 3339. |
| last_seen | string | The last report, UTC; when the visit ended for a final outcome. |
| steps | integer | How many steps, with the hidden-tab spells (away) counted. |
| path | string | The page kinds in order, joined by " > ". |
| journey | string | The steps in the journey format. |
| firings | array | The moments that fired on this visit: { rule, action, step, s, kind, at }, plus order, order_at and value on a fired entry once an order was credited. |
| data | object or null | What the extension stored about the visit. |
query() takes days (1 to 365, default 28), limit (up to
10,000), user, visitor, ref, outcome,
rule (journeys a moment with that id fired in) and fired (any
firing), and returns the records or a WP_Error naming the argument at fault.
$journeys = \WPSignal\Journeys::query( array(
'days' => 7,
'outcome' => 'left',
'limit' => 100,
) );
if ( ! is_wp_error( $journeys ) ) {
foreach ( $journeys as $journey ) {
printf( "%s %s\n", $journey['started_at'], $journey['path'] );
}
}
8. WP-CLI
| Command | Description |
|---|---|
| wp wordsocket journeys list |
Stored journeys, newest first. --count (default 20, up to 1000),
--days (default 28), --user, --visitor,
--ref, --outcome, --rule (a moment id),
--fired, --seeded, --raw (rows as the table
holds them), --fields, --format (table, json, csv, yaml,
count, ids).
|
| wp wordsocket journeys get <journey_id> | One journey: its row, its steps and every firing on it. --format table or json. |
| wp wordsocket journeys purge |
Deletes every stored journey, or with --from and --to
(YYYY-MM-DD, inclusive, on the site's clock) those started between two
days. Counts first and asks; --yes skips the question.
|
| wp wordsocket journeys seed |
Fills the table with made-up visits for a look at the Journeys tab.
--count (default 300, up to 5000) and --months. Refused on a
production environment.
|
| wp wordsocket journeys unseed | Deletes the seeded journeys, and only those. |
wp wordsocket journeys list --days=7 --outcome=left --format=json
wp wordsocket journeys purge --from=2026-08-01 --to=2026-08-31