Free SEO audit for new clients — claim yours
Home/Blog/Analytics/Google Sheets for Marketers: Formulas and Templa…
Analytics

Google Sheets for Marketers: Formulas and Templates That Save Hours

Google Sheets for Marketers: Formulas and Templates That Save Hours
Table of contents
  1. Joining marketing datasets with VLOOKUP, XLOOKUP and INDEX/MATCH
  2. QUERY: SQL-style reporting without leaving the sheet
  3. Cleaning keyword and URL lists in minutes
  4. Pulling page data in with IMPORTXML, IMPORTHTML and connectors
  5. Pivot tables for campaign analysis
  6. Building a weekly marketing dashboard in one tab
  7. Using Gemini and AI functions in Sheets responsibly
  8. Questions marketers ask about Google Sheets formulas
    1. Should I use VLOOKUP or XLOOKUP in Google Sheets?
    2. Why does IMPORTXML return an error or nothing?
    3. Can Google Sheets connect directly to GA4 and Search Console?
    4. How do I stop colleagues breaking formulas in a shared report?
    5. Is it safe to use AI functions in Sheets for client reports?
  9. Rebuilding one recurring report this week
  10. Further reading on Google Sheets for marketers
  11. Sources for this Google Sheets for marketers guide

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.

FormulaSyntaxStrengthsWatch out for
VLOOKUP=VLOOKUP(key, range, column_number, FALSE)Familiar, works everywhereKey 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 defaultRanges must be the same size
INDEX/MATCH=INDEX(result_range, MATCH(key, lookup_range, 0))Flexible, works in older shared templatesHarder 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.

TaskFormula (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:

  1. Paste the raw keyword export into a raw tab and never edit it.
  2. In a clean tab, use =ARRAYFORMULA(LOWER(TRIM(raw!A2:A))) to normalise every keyword at once.
  3. Add a theme column with nested REGEXMATCH tests (for example "price|cost|quote" becomes "pricing intent").
  4. Add the brand flag and word count.
  5. Use QUERY to total search volume and clicks by theme.
  6. 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.

  1. Click inside your data and choose Insert → Pivot table, creating it on a new sheet.
  2. Add the dimension you want as Rows, for example Campaign.
  3. Add a second dimension as Columns if useful, for example Device or Month.
  4. Add Values: Cost (SUM), Conversions (SUM), Clicks (SUM).
  5. 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.
  6. Add a Filter to exclude brand campaigns or a date range.
  7. 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.

TabContainsRule
raw_*Pasted or imported exports, one tab per sourceNever edited by hand; replaced each week
modelCleaned, joined data built with ARRAYFORMULA, XLOOKUP and QUERYFormulas only; no typed numbers
dashboardKPIs, week-on-week changes, small chartsReferences 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:

  1. Never let AI output overwrite source data. Generate into a separate column and compare.
  2. Spot-check a sample. Review at least 20–50 rows of any AI classification before using it in reporting.
  3. Freeze results. AI outputs can change when recalculated; copy and paste as values once you've accepted them, and note the date.
  4. Use deterministic formulas for anything numeric. AI is for language tasks; totals, rates and lookups belong in formulas you can audit.
  5. 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

Sources for this Google Sheets for marketers guide

  1. Semrush: 14 Google Sheets Formulas Every SEO Needs To Know (August 2020)
Rohit Choudhary
Written byRohit ChoudharyCo-Founder, My SEO Experts

Rohit Choudhary is the co-founder of My SEO Experts and has more than 14 years of hands-on experience in SEO, paid advertising and digital marketing. Since starting out in 2011 he has helped hundreds of businesses grow through practical, data-driven search strategies, and he also serves as a consulting Digital Marketing Director for several US-based companies.

Keep reading

Related articles

How to Choose the Primary Keyword for an Existing Page
Analytics

How to Choose the Primary Keyword for an Existing Page

Old pages drift into ranking for searches nobody planned. Here is how to use Search Console data to pick one clear primary keyword and re-center the page without losing what already works.

Ready to grow your business online?

Get a free, no-obligation proposal tailored to your goals and budget.

CallFree Quote