Compare two periods
compare_search_analyticsRun the same search-analytics query over two periods and return per-row and total deltas to answer whether traffic is up or down, which rankings were lost, and which pages grew.
Instructions
Run the same search-analytics query over two periods and return per-row and total deltas. Use it for "is traffic up or down", "what lost rankings", or "which pages grew" questions.
By default the comparison period is the equal-length window immediately before the current one. Set comparison to "yearOverYear" for the same window 364 days earlier (364 rather than 365 keeps weekdays aligned), or "custom" with explicit compareStartDate and compareEndDate.
Rows are matched on their dimension values and sorted by absolute click change, so the biggest movers in either direction come first. Rows present in only one period are included, with the missing side reported as zero.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | ||
| limit | No | How many of the biggest movers to return. Defaults to 50. | |
| endDate | No | Inclusive end date, YYYY-MM-DD, in Pacific Time. Ignored if lastDays is set. | |
| siteUrl | No | Search Console property, exactly as it appears in `list_sites`. URL-prefix properties include the scheme and a trailing slash ("https://example.com/"); domain properties use the "sc-domain:" prefix ("sc-domain:example.com"). These are distinct properties with different data. | |
| lastDays | No | Shorthand for a trailing window, e.g. 28 for "the last 28 days". The window ends 3 days ago because Search Console data is not final before then. Prefer this over startDate/endDate unless you need a specific window. | |
| rowLimit | No | Rows to fetch per period. Defaults to 1000. | |
| startDate | No | Inclusive start date, YYYY-MM-DD, in Pacific Time. Ignored if lastDays is set. | |
| comparison | No | Which period to compare against. Defaults to "previousPeriod". | |
| dimensions | No | Dimensions to group and match on. Omit to compare property-level totals only. Avoid "date" here: it makes every row unique and the comparison meaningless. | |
| compareEndDate | No | End of the comparison period. Required when comparison is "custom". | |
| compareStartDate | No | Start of the comparison period. Required when comparison is "custom". | |
| dimensionFilterGroups | No | Filter groups. Filters inside a group are ANDed together; supplying multiple groups is currently equivalent to one combined AND group in the API. |