How search data gets fetched
Fetching search performance data is an API call, and there are three properties of that data that catch everybody out the first time. None is a problem once you know about it, and all three will make your numbers wrong if you do not.
Key takeaways
- The data lags by two to three days. A weekly fetch must not ask for yesterday.
- Row limits truncate silently. Paginate, and check whether you hit the limit.
- Long-tail and rare queries are withheld entirely, so totals will not reconcile.
- Fetch by query and by page separately; the combination is not always available.
- Store the raw response before grouping, so a rule change can be applied to history.
Three properties that surprise people
- Database
- App integration
- Management
- Analytics
- Front-end & mobile
The delay
Search performance data is not final when it first appears. Numbers for the last two or three days keep moving as data is processed, and a fetch that includes yesterday will produce a figure that is different if you run the same fetch again on Friday.
That produces the specific and maddening failure where a weekly report contradicts itself: this week’s number for last week is not the number you reported last week. So the fetch always asks for a week that ended at least three days ago, and the report says which week it covers.
Row limits
A request returns at most a fixed number of rows, and there is no flag in the response saying “there was more”. A response containing exactly the limit is almost certainly truncated; one containing fewer is complete. Checking that and paginating is three lines and its absence silently discards the long tail, which for a site with any content is most of the queries.
Withheld queries
Rare queries are not returned at all, for privacy reasons that are entirely reasonable. The practical consequence is that summing the query rows gives a smaller total than the site-level total, sometimes much smaller.
That is not an error to be reconciled away. The report states both numbers when they differ materially, because a business whose long tail is forty per cent of its impressions should know that its themed report covers sixty per cent of reality.
Store raw first
- Database
- Management
- Analytics
This is the single most valuable structural decision in the system and it costs a few megabytes a year. Theme rules get refined constantly — a new service line, a realisation that two themes should be one — and a system that only stores grouped totals has to start each new theme from the day it was created.
With raw rows kept, adding a theme in August produces eight months of history for it immediately, which is the difference between a rule change being cheap and being a decision.
Next: how the grouping works.
All posts