Skip to main content
TroopyDocs
Open Troopy
Troopy

API reference / Analytics

Get the revenue insights

Where and when the revenue of the last 30 days comes from, whatever the period of the query: its filters stay. A site that the script saw for the first time less than 30 days ago starts on that day (days). It gives the devices, systems and browsers that bring the most, and the sources and countries that earn and convert best. It also gives the conversion rates of goals, how buyers got to a payment (their visits and days), revenue per visitor week by week, and revenue by weekday and hour. It compares the numbers with the window before, splits visitors and revenue by each dimension, and counts the visitors who did a goal and who paid. The insights need 200 visitors and 5 payments in those days. Until then, ready is false, and have shows the progress.

get/api/v1/analytics/insights

Authorization

HeaderAuthorization: Bearer <API key>
Or the headerX-API-Key: <API key>
API keyMake one in Troopy under Settings > API keys. It acts as you, in its workspace.

Other ways to call it

CLItroopy analytics insights
MCP tooltroopy_get_analytics_insights
Rate limit30 calls in 60 seconds, for each key

Query parameters

periodenum<string>

now is the last 10 minutes. 7d and 30d end today. 3m, 6m and 12m are whole months that end with this month. week starts on Monday. custom needs from and to

nowtodayyesterday24h7d30d3m6m12mweekmonthyearallcustom

Default "30d"

fromstring

YYYY-MM-DD, in the workspace's time zone

date

tostring

YYYY-MM-DD. The period includes this day

date

compareenum<string>

Also gives another window: previous is the window just before, with the same length. year is the same days a year before. custom is compare_from to compare_to

previousyearcustom

compare_fromstring

With compare custom: the first day of the other window

date

compare_tostring

With compare custom: the last day of the other window

date

filter_channelstring

channel: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_referrerstring

referrer: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_utm_sourcestring

utm source: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_utm_mediumstring

utm medium: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_utm_campaignstring

utm campaign: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_utm_termstring

utm term: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_utm_contentstring

utm content: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_refstring

ref: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_sourcestring

source: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_viastring

via: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_pagestring

page: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_entry_pagestring

entry page: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_exit_pagestring

exit page: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_hostnamestring

hostname: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_countrystring

country: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_regionstring

region: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_citystring

city: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_languagestring

language: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_browserstring

browser: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_osstring

os: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_devicestring

device: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_screenstring

screen: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_goalstring

goal: op:value[,value]. The op is is, is_not, contains, does_not_contain, matches (a regular expression) or does_not_match. No op means is. More values mean any of them. (none) matches an empty value, as for direct traffic

At most 500 characters

filter_propertystring

Visitors who sent a goal with a property: op:name=value[,name=value], such as is:plan=pro. The op is one of is, is_not, contains, does_not_contain, matches and does_not_match

At most 500 characters

filter_visit_countstring

Sessions by the visitor's visit number: is:1 (new), gte:2 (returning), lte, is_not

At most 500 characters

Response

200 · application/json
data*object
16 properties
ready*boolean
have*object
2 properties
visitors*integer
payments*integer
need*object
2 properties
visitors*integer
payments*integer
days*integer

The days that the insights read: 30, or fewer for a newer site

totals*object | null
7 properties
visitors*integer
revenue*number
payments*integer
conversionRate*number
revenuePerVisitor*number
dailyVisitors*integer
dailyRevenue*number
shares*array<object>
2 properties
dimension*enum<string>

devicesosbrowsers

rows*array<object>
3 properties
value*string | null
revenue*number
share*number

The share of the period's revenue, 0 to 1

referrers*object
2 properties
byRevenue*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

byConversion*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

countries*object
2 properties
byRevenue*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

byConversion*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

goals*array<object>
3 properties
name*string
visitors*integer
conversionRate*number
purchase*object | null

How buyers got to the payments that tie to them

3 properties
visits*array<integer>

Payments by the visits of their buyer up to them: 1 to 9, then 10 or more

days*array<integer>

Payments by the days from the first visit of their buyer: each day from 0 to 10, then 11-15, 16-20, 21-30 and over 30

median*number | null

The median time from the first visit to the payment, in milliseconds

growth*array<object>

Revenue per visitor, week by week, over the last 6 months

2 properties
at*string

ISO 8601 date and time

value*number
hours*array<object>

In the workspace's time zone. Only the hours with revenue

4 properties
day*integer

0 is Monday

hour*integer
revenue*number
payments*integer
previous*object | null

The same numbers of the window before, as long. A window that is not over compares with the same part of the one before

5 properties
visitors*integer
revenue*number
payments*integer
conversionRate*number
revenuePerVisitor*number
series*array<object>

The window bucket by bucket: hours for one day, else days

5 properties
at*string

ISO 8601 date and time

visitors*integer
revenue*number
renewals*number
payments*integer
split*object

The rows of each dimension that bring the most visitors or revenue, for their share of each

6 properties
channels*object
2 properties
rows*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

revenue*number

The revenue of every row of the dimension, shown or not

referrers*object
2 properties
rows*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

revenue*number

The revenue of every row of the dimension, shown or not

countries*object
2 properties
rows*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

revenue*number

The revenue of every row of the dimension, shown or not

devices*object
2 properties
rows*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

revenue*number

The revenue of every row of the dimension, shown or not

browsers*object
2 properties
rows*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

revenue*number

The revenue of every row of the dimension, shown or not

os*object
2 properties
rows*array<object>
7 properties
value*string | null

null when there is no value, for example no referrer (direct traffic) or an unknown country

visitors*integer
count*integer

Pageviews. For goals, completions. For exit links, clicks

revenue*number

Attributed revenue, in minor units

conversionRate*number

Share of the row's visitors who paid, 0 to 1

timeOnPageinteger | null

Pages only: the average time in view of a visitor, in seconds

scrollDepthinteger | null

Pages only: how far down a visitor read the page on average, 0 to 100

revenue*number

The revenue of every row of the dimension, shown or not

funnel*object | null
3 properties
visitors*integer
engaged*integer

Visitors who did a goal

buyers*integer

Visitors who paid

Errors

400 invalid_inputFix the field named in detail. Each operation's schema is in /api/v1/openapi.json.
401 unauthorizedSend an API key as `Authorization: Bearer tr_live_...`. Create one in Troopy under Settings.
403 forbiddenThe key lacks a scope this operation needs, or its owner lacks the role. detail says which; create a key with the scope, or ask an organization owner or admin.
429 rate_limitedWait the number of seconds in Retry-After, then retry.