Skip to content

Request Parameters

Build realtime and reporting requests for the GoodMetrics REST API.

This page describes REST API request parameters.

GoodMetrics has two REST API request styles:

  • Realtime endpoints use the current live window automatically.
  • Reporting endpoints use flat query parameters for date ranges, filters, sorting, and pagination.

Realtime endpoints read from GET /{gmID}/events/realtime/{resource}.

Bearer-token realtime requests use the current live window automatically, so no timestamp query parameter is required.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/realtime/pages" \
-H "Authorization: Bearer YOUR_API_KEY"

Reporting endpoints read from GET /{gmID}/events/{resource}?start={start}&end={end}.

start and end are Unix timestamps. Unix seconds are recommended. The API also accepts millisecond timestamps and normalizes them internally.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/audience/countries?start=1771872000&end=1772476799&page=1&limit=10&sort_by=uniqueVisitors&dir=desc" \
-H "Authorization: Bearer YOUR_API_KEY"

Every reporting request needs a primary date range:

ParameterDescription
startPrimary range start timestamp.
endPrimary range end timestamp.

Pass a comparison range to receive primary, secondary, and change arrays in supported responses.

ParameterDescription
compare_startComparison range start timestamp.
compare_endComparison range end timestamp.
Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/audience/countries?start=1771872000&end=1772476799&compare_start=1771267200&compare_end=1771871999" \
-H "Authorization: Bearer YOUR_API_KEY"

Each range must include both start and end values, and each start value must be before its end value.

Filters are written as {field}_{operator} query parameters. Use comma-separated values for multiple matches.

Operator suffixBehavior
_isInclude exact values.
_is_notExclude exact values.
_containsInclude values containing text.
_not_containsExclude values containing text.

Examples include country_is=Canada, country_is=Canada,United States, page_contains=/pricing, page_not_contains=/admin, and event_type_is=signup,upgrade_to_paid.

Supported filter fields:

browser, city, country, device, eventType, eventURL, exitPage, initialLandingPage, initialReferrer, initialUtmSource, initialUtmMedium, initialUtmSourceMedium, isNewVisitor, language, landingPage, operatingSystem, page, referrer, region, utmCampaign, utmContent, utmMedium, utmSource, utmSourceMedium, utmTerm, subdomain.

Use snake-case field names in the URL:

FieldQuery parameter examples
eventTypeevent_type_is=signup
eventURLevent_url_contains=/checkout
initialLandingPageinitial_landing_page_contains=/docs
utmSourceMediumutm_source_medium_is=google / cpc

Use is_new_visitor=true or is_new_visitor=false for the new-versus-returning visitor filter.

If inclusive and exclusive operators are mixed on the same field, inclusive operators take precedence.

Use the event_type_is filter to select custom events by event name or event ID.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/custom/top-events?start=1771872000&end=1772476799&event_type_is=signup%2Cupgrade_to_paid" \
-H "Authorization: Bearer YOUR_API_KEY"

When no event type filter is provided, custom-event-aware endpoints use all available events for the site.

Use sort_by and dir, for example sort_by=uniqueVisitors&dir=desc.

Sort fields vary by endpoint. Common fields include sessions, uniqueVisitors, newVisitors, pageViews, eventCompletions, eventValue, eventConversionRate, and total.

dir may be asc or desc.

Table endpoints support page-based pagination and cursor reuse.

ParameterDescription
pagePage number to fetch.
limitNumber of rows per page.
cursorCursor returned by an earlier table response.
Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/audience/countries?start=1771872000&end=1772476799&page=1&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"

The first response returns meta.cursor. Include that value in later requests to fetch additional pages from the same result set.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/audience/countries?start=1771872000&end=1772476799&page=2&limit=10&cursor=returned-cursor" \
-H "Authorization: Bearer YOUR_API_KEY"

/charts/overview supports type and interval.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/charts/overview?start=1771872000&end=1772476799&type=unique_visitors&interval=day" \
-H "Authorization: Bearer YOUR_API_KEY"

Supported intervals are hour, day, week, and month.

Session-centric chart types include unique_visitors, page_views, visits, page_views_per_visit, bounce_rate, and avg_visit_duration.

When a request is event-centric because it has a page or subdomain filter, chart types include avg_time_on_page, visits, pageviews, and unique_visitors.

Some table and custom-event responses include event conversion rates. Use event_conversion_cohort=visitors to choose the denominator.

Supported values are sessions, visitors, page_views, and sessions_with_page_views. The default is sessions.