Every marketing tool has an export button, and almost every export ends up in a spreadsheet. Search Console queries, GA4 landing pages, Google Ads search terms, a crawl of the site, a CRM list of closed deals: the analysis that actually drives decisions usually happens after these have been pasted side by side in Google Sheets.
Yet most marketers use a small fraction of what Sheets can do. They filter by hand, copy and paste lookups row by row, and rebuild the same weekly report from scratch every Monday. The formulas that remove that work aren't obscure; they just aren't taught in context.
This guide covers the formulas and workflows that save the most time in SEO, PPC and reporting work: joining datasets with lookups, querying data with SQL-like syntax, cleaning keyword and URL lists, pulling page data in with IMPORTXML, analysing campaigns with pivot tables, building a lightweight dashboard, and using Gemini's AI features without letting them corrupt your numbers. Every example uses formulas you can paste in and adapt.
Joining marketing datasets with VLOOKUP, XLOOKUP and INDEX/MATCH
Most marketing questions need two datasets joined on a shared key. Which ranking pages convert? Join Search Console page data to GA4 landing page data on URL. Which search terms produced revenue? Join the Google Ads search terms report to conversion data on the term. Lookups do that join.
| Formula | Syntax | Strengths | Watch out for |
|---|---|---|---|
| VLOOKUP | =VLOOKUP(key, range, column_number, FALSE) | Familiar, works everywhere | Key must be in the first column; inserting a column breaks the column number; forgetting FALSE returns wrong matches |
| XLOOKUP | =XLOOKUP(key, lookup_range, result_range, "not found") | Looks left or right, built-in "not found" value, exact match by default | Ranges must be the same size |
| INDEX/MATCH | =INDEX(result_range, MATCH(key, lookup_range, 0)) | Flexible, works in older shared templates | Harder to read for colleagues |
For new work, use XLOOKUP. A typical SEO join looks like this, with Search Console pages in column A of one tab and a GA4 landing page export on a tab called ga4:
=XLOOKUP(A2, ga4!A:A, ga4!D:D, 0)
That returns the key events for each ranking page, or 0 if GA4 has no matching row. The most common reason lookups fail in marketing data isn't the formula; it's the key. Search Console exports full URLs (https://www.example.com/pricing/) while GA4 exports paths (/pricing/), sometimes with query strings. Normalise both sides before joining, using the cleaning formulas further down, and the match rate jumps.
A second tip: wrap lookups in ARRAYFORMULA or use MAP so one formula fills the whole column. That way new rows pasted in next month calculate automatically:
=ARRAYFORMULA(IF(A2:A="", , XLOOKUP(A2:A, ga4!A:A, ga4!D:D, 0)))
QUERY: SQL-style reporting without leaving the sheet
QUERY is the single most useful formula for marketers who handle exports. It filters, aggregates, sorts and limits a range using a language similar to SQL, and the output updates whenever the source data changes.
The syntax is =QUERY(range, "query text", header_rows). Columns are referred to by letter. A few patterns cover most reporting needs:
- Top pages by clicks with a minimum impression floor:
=QUERY(gsc!A:E, "select A, sum(B), sum(C) where C > 100 group by A order by sum(B) desc limit 25", 1) - Google Ads campaigns with cost but no conversions:
=QUERY(ads!A:F, "select A, sum(D) where E = 0 group by A order by sum(D) desc", 1) - Keywords in positions 8 to 20 (striking distance):
=QUERY(gsc!A:E, "select A, C, E where E >= 8 and E <= 20 order by C desc", 1) - Monthly totals pivoted by channel:
=QUERY(data!A:D, "select A, sum(C) group by A pivot B", 1)
Two gotchas catch everyone. First, QUERY decides each column's data type from the majority of values, so a column of numbers with a few text entries such as "<10" may return blanks for the text rows. Clean the column first. Second, when you feed QUERY an array built from other formulas, refer to columns as Col1, Col2 instead of letters.
The striking-distance query above is the starting point for one of the quickest SEO wins there is; our guide to striking distance keywords explains what to do with the list.
Cleaning keyword and URL lists in minutes
Raw exports are messy: inconsistent capitalisation, trailing spaces, tracking parameters, duplicate rows from different tools. Cleaning by hand is slow and error-prone. Semrush's long-running list of Sheets formulas for SEO makes the same point:
“As SEOs, we don’t want to spend all our time cleaning up messy spreadsheets.”
— Semrush, 14 Google Sheets Formulas Every SEO Needs To Know
These are the formulas that handle most cleaning tasks. Put them in helper columns next to the raw data, never over it.
| Task | Formula (for a value in A2) |
|---|---|
| Lowercase and trim spaces from a keyword | =LOWER(TRIM(A2)) |
| Strip query strings and fragments from a URL | =REGEXREPLACE(A2, "[?#].*$", "") |
| Extract the path from a full URL | =REGEXEXTRACT(A2, "https?://[^/]+(/.*)") |
| Extract the domain | =REGEXEXTRACT(A2, "https?://([^/]+)") |
| Get the first folder (site section) | =REGEXEXTRACT(A2, "https?://[^/]+/([^/]+)/") |
| Add a trailing slash if missing | =IF(RIGHT(A2,1)="/", A2, A2&"/") |
| Flag question keywords | =REGEXMATCH(A2, "^(how|what|why|when|where|who|can|does|is) ") |
| Count words in a keyword | =COUNTA(SPLIT(A2, " ")) |
| Deduplicate a whole list | =UNIQUE(A2:A) |
| Flag duplicates in place | =COUNTIF(A$2:A, A2) > 1 |
| Brand vs non-brand flag | =IF(REGEXMATCH(LOWER(A2), "acme|acmee|acme co"), "brand", "non-brand") |
The regular expressions here follow the RE2 syntax that Sheets uses, which is also what Search Console's regex filters use. If you build a brand regex in Sheets, you can paste it straight into the Search Console performance report filter; our guide to regex in Search Console has more patterns.
A simple keyword-grouping workflow using these:
- Paste the raw keyword export into a
rawtab and never edit it. - In a
cleantab, use=ARRAYFORMULA(LOWER(TRIM(raw!A2:A)))to normalise every keyword at once. - Add a theme column with nested
REGEXMATCHtests (for example "price|cost|quote" becomes "pricing intent"). - Add the brand flag and word count.
- Use
QUERYto total search volume and clicks by theme. - Sort themes by opportunity and turn the top ones into briefs.
Pulling page data in with IMPORTXML, IMPORTHTML and connectors
IMPORTXML fetches a public web page and extracts whatever an XPath expression points to. For SEO spot checks across a few dozen URLs, it's a free mini-crawler.
- Title tag:
=IMPORTXML(A2, "//title") - Meta description:
=IMPORTXML(A2, "//meta[@name='description']/@content") - H1:
=IMPORTXML(A2, "//h1") - Canonical:
=IMPORTXML(A2, "//link[@rel='canonical']/@href") - Robots meta:
=IMPORTXML(A2, "//meta[@name='robots']/@content") - All links on a page:
=IMPORTXML(A2, "//a/@href")
IMPORTHTML(url, "table", 1) pulls the first HTML table on a page, useful for public data tables. IMPORTRANGE pulls a range from another spreadsheet, which lets each client or team keep its own sheet while a master sheet aggregates them.
Know the limits before relying on these for anything important:
- They fetch raw HTML without running JavaScript, so content injected by scripts won't appear. That's a feature for SEO checks (it's roughly what a non-rendering crawler sees) but a limitation for analysis.
- Many import formulas in one sheet slow it down and can return "Loading…" or errors for a while; sites with bot protection may block the requests entirely.
- Results refresh on Google's schedule, not on demand, so don't treat them as live monitoring.
Beyond a few dozen URLs, use a proper crawler, ideally with custom extraction, and import its export instead. For analytics data, connectors and add-ons from the Google Workspace Marketplace can pull GA4, Search Console or ad platform data on a schedule, and Connected Sheets can query BigQuery tables directly. If your GA4 data already lives in BigQuery, see our GA4 BigQuery export guide for queries worth bringing into Sheets.
Pivot tables for campaign analysis
Pivot tables answer "how does X break down by Y" questions without writing formulas. They're ideal for search terms reports, campaign exports and CRM deal lists.
- Click inside your data and choose Insert → Pivot table, creating it on a new sheet.
- Add the dimension you want as Rows, for example Campaign.
- Add a second dimension as Columns if useful, for example Device or Month.
- Add Values: Cost (SUM), Conversions (SUM), Clicks (SUM).
- Add a calculated field for cost per conversion, for example
=Cost/Conversions, and for conversion rate,=Conversions/Clicks. Calculated fields compute on the totals, which avoids the classic mistake of averaging row-level percentages. - Add a Filter to exclude brand campaigns or a date range.
- Sort rows by cost descending so the money is at the top.
Worked example (hypothetical numbers): a pivot of a Google Ads search terms export by match type shows broad match terms spent 4,200 with 21 conversions (cost per conversion 200), phrase spent 2,600 with 26 (100), exact spent 1,900 with 24 (about 79). Adding Device as columns reveals that most of broad match's cost came from mobile with few conversions. That's a five-minute analysis that points directly to search terms clean-up and bid adjustments.
Building a weekly marketing dashboard in one tab
“Google Sheets is a powerful (and free) cloud-based tool that allows us to organize data effectively and efficiently.”
— Semrush, 14 Google Sheets Formulas Every SEO Needs To Know
For a small team, a single well-built sheet often beats a dashboard tool nobody opens. The structure that holds up best uses three layers.
| Tab | Contains | Rule |
|---|---|---|
raw_* | Pasted or imported exports, one tab per source | Never edited by hand; replaced each week |
model | Cleaned, joined data built with ARRAYFORMULA, XLOOKUP and QUERY | Formulas only; no typed numbers |
dashboard | KPIs, week-on-week changes, small charts | References model only; protected from editing |
Useful dashboard formulas:
=SUMIFS(model!D:D, model!A:A, ">="&B1, model!A:A, "<="&C1)totals a metric between two dates in cells B1 and C1, so the whole dashboard changes when you change the dates.=SPARKLINE(model!D2:D13)draws a tiny trend line inside a cell.=IFERROR(B5/C5-1, "")calculates week-on-week change without ugly errors.- Conditional formatting (green above target, red below) does more for readability than any chart.
Worked example (hypothetical): a local services business tracks five numbers weekly: sessions, leads, cost, cost per lead and booked jobs from the CRM. Weekly leads of 62 against 48 the previous week show as +29% in green; cost per lead of 38 against a target of 45 also shows green; booked jobs, pulled by IMPORTRANGE from the sales team's sheet, show 19. The owner reads it in thirty seconds. When it outgrows a sheet, the same model tab can feed Data Studio (the renamed Looker Studio); our marketing dashboard guide covers when to make that move.
One caution: Google Sheets has a cell limit per spreadsheet, and large daily exports hit it surprisingly fast. Aggregate before importing (weekly by page rather than daily by page and query) and archive old raw tabs.
Using Gemini and AI functions in Sheets responsibly
Google has been adding Gemini features to Sheets, including help writing formulas, generating tables and an AI function that runs a prompt against cell contents. Availability depends on your Workspace plan and region, so check what your account offers. These features are genuinely useful for marketers, within limits.
Good uses:
- Writing or explaining a complex formula ("write a QUERY that totals cost by campaign where conversions are zero").
- Classifying keywords or search terms into intent groups as a first pass.
- Drafting ad headline variations or meta descriptions from a product list, for human editing.
- Summarising open-text survey responses into themes.
Rules that keep your numbers safe:
- Never let AI output overwrite source data. Generate into a separate column and compare.
- Spot-check a sample. Review at least 20–50 rows of any AI classification before using it in reporting.
- Freeze results. AI outputs can change when recalculated; copy and paste as values once you've accepted them, and note the date.
- Use deterministic formulas for anything numeric. AI is for language tasks; totals, rates and lookups belong in formulas you can audit.
- Mind what you send. Don't paste customer personal data into prompts unless your organisation's policies and Workspace settings allow it. Our guide to marketing privacy laws covers the obligations.
Combined with well-structured prompts, AI in Sheets turns a two-hour keyword classification job into twenty minutes of generation and review. The review part isn't optional.
Questions marketers ask about Google Sheets formulas
Should I use VLOOKUP or XLOOKUP in Google Sheets?
Use XLOOKUP for new work. It can look left or right, has a built-in value for missing matches and uses exact matching by default, which avoids the most common VLOOKUP error. Keep VLOOKUP only for shared templates where colleagues expect it.
Why does IMPORTXML return an error or nothing?
Common causes are content that is loaded by JavaScript (IMPORTXML reads raw HTML only), an XPath that does not match the page, sites that block automated requests, or too many import formulas in one sheet. Test the XPath on one URL first and keep the number of imports modest.
Can Google Sheets connect directly to GA4 and Search Console?
Yes, through add-ons from the Google Workspace Marketplace or via Connected Sheets if your data is in BigQuery. For simple weekly reporting, scheduled exports or an add-on are enough; for larger datasets, query BigQuery and bring only the aggregated results into Sheets.
How do I stop colleagues breaking formulas in a shared report?
Separate raw, model and dashboard tabs, protect the model and dashboard ranges, use ARRAYFORMULA so formulas cover whole columns, and rely on version history to restore anything that does get overwritten.
Is it safe to use AI functions in Sheets for client reports?
For language tasks such as classification and drafting, yes, with review. Generate into separate columns, spot-check samples, freeze accepted results as values and keep all numeric calculations in ordinary formulas.
Rebuilding one recurring report this week
Pick the report you rebuild most often. Split it into raw, model and dashboard tabs, replace manual lookups with XLOOKUP, replace manual filtering with QUERY, and add a date selector with SUMIFS. The first rebuild takes an afternoon; every week after that takes minutes.
If you'd rather have your SEO and PPC reporting built and maintained for you, our SEO and PPC management teams include clear, automated reporting with every engagement. Get a quote to discuss what you need.
Further reading on Google Sheets for marketers
- GA4 BigQuery Export: When You Need It and How to Start
- GA4 Data Thresholds and Sampling: Why Your Numbers Look Off
- GA4 Custom Channel Groups: Fix '(Unassigned)' and Misattributed Traffic




