The metrics mutation combines page analytics, PageSpeed data and Google Search performance for one URL. Results are cached for one hour and may contain partial data when an analytics provider reports an error.
GraphQL Page Metrics
Start with PagibleAI GraphQL API for authentication and error handling. Use GraphQL Pages when you need to act on the results by updating or publishing content.
Request page metrics
mutation PageMetrics($url: String!, $days: Int, $lang: String) {
metrics(url: $url, days: $days, lang: $lang) {
errors
views { key value rows { key value } }
visits { key value rows { key value } }
conversions { key value rows { key value } }
durations { key value rows { key value } }
countries { key value rows { key value } }
referrers { key value rows { key value } }
pagespeed { key value rows { key value } }
impressions { key value rows { key value } }
clicks { key value rows { key value } }
ctrs { key value rows { key value } }
queries { key impressions clicks ctr position }
}
}
{
"url": "https://www.example.com/guides/getting-started",
"days": 30,
"lang": "en"
}
metrics arguments
The caller needs page:metrics permission. The optional lang argument is accepted for API compatibility, but the current resolver does not vary provider requests or cache entries by language. Analytics, search and PageSpeed integrations must be configured for their corresponding fields to contain data.
Stats fields
Stats
StatsNumber fields
StatsNumber
StatsQuery fields
StatsQuery
Example response
{
"data": {
"metrics": {
"errors": [],
"views": [
{"key": "2026-07-01", "value": 150, "rows": []}
],
"visits": [
{"key": "2026-07-01", "value": 98, "rows": []}
],
"countries": [
{"key": "DE", "value": 54, "rows": []}
],
"impressions": [
{"key": "2026-07-01", "value": 1200, "rows": []}
],
"clicks": [
{"key": "2026-07-01", "value": 85, "rows": []}
],
"ctrs": [
{"key": "2026-07-01", "value": 0.071, "rows": []}
],
"queries": [
{
"key": "laravel cms",
"impressions": 1200,
"clicks": 85,
"ctr": 0.071,
"position": 4.2
}
]
}
}
}
Partial failure response
Each analytics source is collected independently. One failure can therefore produce an errors entry while other fields still contain useful data:
{
"data": {
"metrics": {
"errors": [
"Search provider credentials are missing"
],
"views": [
{"key": "2026-07-01", "value": 150, "rows": []}
],
"impressions": null,
"clicks": null,
"ctrs": null,
"queries": null,
"pagespeed": [
{"key": "performance", "value": 0.92, "rows": []}
]
}
}
}
Empty result response
{
"data": {
"metrics": {
"errors": [],
"views": [],
"visits": [],
"queries": []
}
}
}
An empty array means the configured provider returned no rows for that field. null usually means the resolver received no value for the field, often because its source failed or is unavailable. Handle those states separately.
Caching and partial failures
Analytics, search queries and PageSpeed results are cached for 3,600 seconds. If one source fails, the resolver adds its message to errors and still returns data collected from the other sources. Treat every stats field as nullable and show provider errors separately from an empty result.
Metrics cache keys
Normalize equivalent URLs before requesting metrics. Differences in scheme, host casing, trailing slashes or query strings create separate cache entries and may also refer to different records at the analytics provider.
Use metrics safely
Request only URLs the authenticated editor is allowed to analyze, and avoid exposing raw provider errors to public visitors. Metrics are an administrative GraphQL feature; use the read-only JSON:API or rendered pages for public content delivery.