country-device
Country and Device Performance
Build a markets table and a device table for one property, find the gaps (markets where the position is fine but the CTR is low, declines that only mobile shows), and recommend fixes. The user's request may contain a property (a GSC site URL or a recognizable name), a date range, a country (a name or an ISO 3166-1 alpha-3 code), a device, or a URL path to narrow the winners and losers step.
Workflow
-
Resolve the property. If the user's request or the conversation names a property, use it. Site URLs use GSC formats:
sc-domain:example.comorhttps://www.example.com/. Otherwise calllist_sitesand pick the obvious match. If several plausible properties exist, ask the user which one before continuing. -
Anchor and windows. Call
get_site_summarywithdays: 28, or withstartDate/endDatewhen the user gave dates (a date you pass always wins anddaysonly sizes an edge you leave out). Use the last 28 days compared with the previous period unless the user specifies dates.- Read
currentandprevious(clicks,impressions,ctr,avgPosition) anddeltas(clicks,impressions,ctrPoints,positionDelta). - Keep
range.startDate/range.endDateandcomparison.startDate/comparison.endDatefrom the response and pass those exact dates to every later call, so all sections line up. - GSC data lags about 2 to 3 days: never treat the most recent 2 days as complete, and if a dip appears at the very edge of the range, say it is likely reporting lag, not a real drop.
- Read
-
Markets.
query_countriestakes a single date range and no comparison argument, so call it twice: once with the current window and once with the comparison window, withlimit: 25(raise it, or page withoffsetset topagination.nextOffset, when the user wants more markets).- Rows are
countries[]withcountry,clicks,impressions,ctr(0-100) andposition, sorted by clicks. Country codes are lowercase ISO 3166-1 alpha-3 as the tools return them (for exampleusa,gbr,deu); print the country name next to the code and keep the code, in that case, for filters, since anequalsmatch is case-sensitive on both data paths. - Join the two calls by
countryand derive the click, impression, CTR-point and position deltas; say they are derived. Quote property totals fromcoverage.siteTotals, not from summed rows, and give each top market's share of total clicks as a derived figure.
- Rows are