Skip to main content

Query your metrics

Ask a precise question of your data — a count, a sum, broken down by day or by campaign — and get back rows scoped to your account.

Analytics queries follow one consistent shape no matter what you're measuring. You name the measures you want (counts, sums), the dimensions to break them down by, an optional time range, and any filters. The query host returns rows. Because your token is scoped to your account, results are automatically restricted to your own data — there's no filter you have to add to keep other accounts' numbers out, and no way to reach them.

Before you begin​

  • An analytics token. Mint one as described in Authenticate. It's valid for about 5 minutes.

The query format​

A query is a JSON object with these fields — all optional except that you need at least one measure or dimension:

FieldWhat it doesExample
measuresThe numbers to compute (counts, sums).["conversions_unified.count"]
dimensionsAttributes to group rows by.["conversions_unified.conversion_status"]
timeDimensionsA date field plus a granularity (day, week, month) and a dateRange.see below
filtersConditions that narrow the rows.[{ "member": "…conversion_status", "operator": "equals", "values": ["LOCKED"] }]
orderSort order for the result rows.{ "conversions_unified.event_date": "asc" }
limit / offsetCap the rows returned and page through the rest."limit": 1000

You pass the query as a URL-encoded query parameter to the load endpoint at https://cube.paylode.com/cubejs-api/v1/load.

A worked example — conversions per day​

This asks: how many conversions did I get per day over the last 30 days?

curl -G https://cube.paylode.com/cubejs-api/v1/load \
-H "Authorization: eyJhbGciOiJIUzI1NiJ9.EXAMPLE_PAYLOAD.EXAMPLE_SIGNATURE" \
--data-urlencode 'query={
"measures": ["conversions_unified.count"],
"timeDimensions": [{
"dimension": "conversions_unified.event_date",
"granularity": "day",
"dateRange": "last 30 days"
}],
"order": { "conversions_unified.event_date": "asc" }
}'
const query = {
measures: ["conversions_unified.count"],
timeDimensions: [
{
dimension: "conversions_unified.event_date",
granularity: "day",
dateRange: "last 30 days",
},
],
order: { "conversions_unified.event_date": "asc" },
};

const url =
"https://cube.paylode.com/cubejs-api/v1/load?query=" +
encodeURIComponent(JSON.stringify(query));

const { data } = await fetch(url, {
headers: { Authorization: token }, // raw token, no "Bearer" prefix
}).then((r) => r.json());

The result is one row per day (trimmed):

{
"data": [
{ "conversions_unified.event_date.day": "2026-05-03T00:00:00.000", "conversions_unified.count": "12" },
{ "conversions_unified.event_date.day": "2026-05-04T00:00:00.000", "conversions_unified.count": "9" },
{ "conversions_unified.event_date.day": "2026-05-05T00:00:00.000", "conversions_unified.count": "15" }
]
}

Measure values come back as strings — parse them to numbers before doing math. Each row's date field is suffixed with the granularity you asked for (event_date.day).

To break the same count down another way, add a dimension. For example, group by conversion status by adding "dimensions": ["conversions_unified.conversion_status"] — you'll get one row per (day, status) pair.

note

Pass the token in Authorization without a Bearer prefix — see Authenticate.

Choose a date range​

dateRange takes either a relative phrase or a pair of dates:

  • Relative ranges cover complete days. "last 7 days" means the seven full days before today: it stops at the end of yesterday, so nothing from today is in it.
  • To include today, use "from 7 days ago to now".
  • For a fixed window, pass two dates: ["2026-10-01", "2026-10-31"]. Both days are included.

Dates are in UTC.

note

Checking a link you just clicked? Use a range that includes today, and allow for the refresh lag described in Data freshness: new clicks take a few hours to appear.

Filter on one cmeta attribute​

Click and conversion rows carry all of your custom attributes in a single cmeta dimension, as JSON text:

{"utm_term": "spring", "cmeta_campaign": "sms", "cmeta_user_id": "a1b2c3"}

There's no separate dimension per attribute. To filter on one, match its key and value together with the contains operator:

"filters": [{
"member": "clicks_unified.cmeta",
"operator": "contains",
"values": ["\"cmeta_campaign\": \"sms\""]
}]
  • Several values in one filter match a row that has any of them, e.g. ["\"cmeta_campaign\": \"sms\"", "\"cmeta_campaign\": \"email\""].
  • Several filters in the list must all match.
caution

This is a text match, so it must match the stored text exactly: the quotes, the colon and the space after it. Before filtering, add cmeta as a dimension and look at a few rows to copy the key exactly as it comes back. Matching the value alone ("sms") also catches any other attribute that contains it.

Page through large results​

A request returns at most 10,000 rows when you don't set limit, and at most 50,000 when you do. To read more, page with limit and offset, and set an order so every page sorts rows the same way:

"order": {
"clicks_unified.created_at": "asc",
"clicks_unified.click_id": "asc"
},
"limit": 1000,
"offset": 0

Raise offset by limit for each next page (0, 1000, 2000, …). A page that returns fewer rows than limit is the last one.

Discover what's available​

Each metric belongs to a named view (like conversions_unified), and each view offers its own measures and dimensions. To see everything your token can query, call the meta endpoint:

curl https://cube.paylode.com/cubejs-api/v1/meta \
-H "Authorization: eyJhbGciOiJIUzI1NiJ9.EXAMPLE_PAYLOAD.EXAMPLE_SIGNATURE"

The response lists every view visible to your account with its measures and dimensions — names, types, and titles. It's the authoritative catalog: when you wonder "can I group conversions by that?", /meta answers it. Any member you see there can go straight into a query's measures, dimensions, or filters.

Product-focused walkthroughs of the most useful views:

For the token endpoint schema and the analytics query host, see the API Reference.