Using the Insights API
Insights API Documentation
The Insights API allows you fetch insights on search terms that returned results and search terms that did not return any results.
Authentication
Clients calling the API are required to add an authentication header with the valid authentication token.
Authorization: Bearer {ACCESS_TOKEN}
Data needed to consume API can be found in your WP Admin area in the WP Engine Smart Search tab under Settings
.
Query
Sample Query:
{
insights {
searchTerms {
term
numberOfSearches
}
searchTermsNoResults {
term
numberOfSearches
}
from
to
}
}
Result:
{
"data": {
"insights": {
"searchTerms": [
{
"term": "hello",
"numberOfSearches": 5
},
{
"term": "sample page",
"numberOfSearches": 3
}
],
"searchTermsNoResults": [
{
"term": "shoes",
"numberOfSearches": 3
}
],
"from": "2023-12-05T13:25:44",
"to": "2023-12-12T13:25:44"
}
}
}
Filtering by time window
- If the values for
to
andfrom
are not provided the following values are the defaults:to: now
from: 7 days ago
- You can filter by a time window using the
from
andto
input variables These variables accept the URX time formatyyyy-MM-ddTHH:mm:ss
- The example below filters insights data from the
5th of December 2023 at 1pm
to the12th of December 2023 at 1pm
.
Sample Query:
{
insights(
from: "2023-12-05T13:00:00",
to: "2023-12-12T13:00:00"
) {
searchTerms {
term
numberOfSearches
}
searchTermsNoResults {
term
numberOfSearches
}
from
to
}
}