If you build or maintain sites for criminal defense firms, sooner or later the lawyer asks a fair question: which charge pages are working? The Search Console web interface can answer that one page at a time, but it gets slow once a site has forty charge pages, a dozen court pages and a blog. Exporting by hand every month is tedious and easy to get wrong.

The Search Console API makes this repeatable. With one script you can pull clicks, impressions and queries for every URL, group them by charge and hand the firm a report that maps search data to the cases they actually take. This post covers the parts of the API that matter for that job and the traps that catch people the first time.

What the API gives you

The searchanalytics.query method returns rows of performance data for a property. You choose the date range, the dimensions to group by and optional filters. Useful dimensions for a law firm report are page, query, date, device and country. Each row comes back with clicks, impressions, click-through rate and average position.

A few limits shape how you write the script. Google's reference says rowLimit accepts values from 1 to 25,000 and defaults to 1,000. To get more rows you page through with startRow. Google also notes that the method returns top rows rather than every possible row, and its guide on getting all your data says the method exposes at most 50,000 rows per day per search type. For a typical defense firm site that ceiling rarely matters, but it is worth knowing before you promise a complete query list.

Data usually appears after a delay of two to three days, so set your end date accordingly or the last few days will look empty.

Map URLs to charges

The useful part of this report is the mapping. Defense firm sites tend to follow predictable URL patterns, so a small lookup table does the job. Keep it in a config file the firm can read:

CHARGE_MAP = { "/charges/dui": "DUI", "/charges/drug": "Drug crimes", "/charges/domestic-violence": "Domestic violence", "/courts/": "Court pages", "/process/": "Process pages", } def label(url): path = url.split("://", 1)[-1].split("/", 1)[-1] for prefix, name in CHARGE_MAP.items(): if ("/" + path).startswith(prefix): return name return "Other" 

Pull rows with dimensions page and query, label each row, then sum clicks and impressions by label. The firm gets totals per charge, and you keep the query detail underneath for anyone who wants to dig in.

Filter out noise before you report

Two kinds of rows distort a local law firm report. Branded queries, which include the firm or lawyer name, inflate clicks on the homepage and bio pages. Foreign impressions can pile up on pages that a scraper copied or that match an unrelated query abroad.

Handle both with filters. The API supports filter operators including equals, contains, notContains and regex matching, so you can exclude branded terms with a regex and limit the country to the United States in the same request. Keep a separate branded report, because lawyers do want to know how many people search their name.

Compare periods the same way every month

A single month of data tells you little. Store each pull in a small database or a dated CSV, then compare the same date ranges: last 28 days against the previous 28, and this month against the same month last year. Seasonal patterns are real in criminal defense. Holiday periods, school calendars and enforcement campaigns all shift search behavior, so year-over-year comparisons are often the fairer view.

Note any site changes alongside the data: a rewritten DUI page, a new court page, a redirect batch. When a number moves, the lawyer will ask why, and a change log answers that faster than guessing.

Present it for lawyers

Lawyers are busy and skeptical of marketing reports full of charts. Keep the output short:

  1. One table of clicks and impressions by charge, this period against the last.
  2. The three charge pages with the biggest gains and the three with the biggest losses.
  3. New queries that appeared this month, which often point to questions the site does not answer.

That last list tends to spark the most useful conversations. If people are suddenly searching a new phrase about license hearings, the firm may need a new section on the DUI page.

For more on analytics and search data for legal sites, the collection of legal marketing analytics and search data guides has related pieces. Once the report exists, this article on using Search Console queries to choose which charge page to fix explains how a firm can act on it.

Questions about the Search Console API

Do I need a service account?

You can use OAuth as a user or a service account. A service account works well for scheduled scripts, but it must be added as a user on the Search Console property before it can read data.

Why do API totals differ from the web interface?

Grouping by query drops some anonymized queries, so totals grouped by page and query can be lower than page-only totals. Compare like with like.

How often should the script run?

Monthly is enough for most firms. Daily pulls help only if you are tracking a specific change and want a stored history.

SBD Marketing works only with criminal defense law firms, one firm per city, and helps them with website design, SEO for the charges they defend, visibility in AI search tools and SEO audits.