Spreadsheet Practice

How to build UTM tracking links in Excel

Formula (Excel and Google Sheets)

=A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium="&C2&"&utm_campaign="&D2

Join the base URL and the parameters with &: =A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium="&C2&"&utm_campaign="&D2.

Result on the example
one result per row in E2, filled down to E6
Works in
Excel 2019 and later, including Microsoft 365
Google Sheets
Same formula

See it work

The formula is already in E2, filled down to E6. Change any input and the result updates, or edit the formula to experiment.

How it works

A query string starts with ? and separates parameters with &. The IF checks whether the base URL already has a ? (row 4 does) and picks the right joiner. The rest is plain joining: each parameter name in quotes, then the cell with its value.

=A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium="&C2&"&utm_campaign="&D2

Result"https://northwind.example/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_2026"

  1. A2"https://northwind.example/spring-sale"

    The value in A2.

  2. FIND("?",A2)#VALUE!

    FIND: Position of text, case-sensitive.

    • find_text"?"
    • within_textA2"https://northwind.example/spring-sale"
  3. ISNUMBER(FIND("?",A2))FALSE

    ISNUMBER: TRUE if the value is a number.

    • valueFIND("?",A2)#VALUE!
  4. IF(ISNUMBER(FIND("?",A2)),"&","?")"?"

    IF: Returns one value if a test is true, another if false.

    • logical_testISNUMBER(FIND("?",A2))FALSE
    • value_if_true"&"not used
    • value_if_false"?"
  5. A2&IF(ISNUMBER(FIND("?",A2)),"&","?")"https://northwind.example/spring-sale?"

    The & operator joins as text.

  6. A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source=""https://northwind.example/spring-sale?utm_source="

    The & operator joins as text.

  7. B2"newsletter"

    The value in B2.

  8. A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2"https://northwind.example/spring-sale?utm_source=newsletter"

    The & operator joins as text.

  9. A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium=""https://northwind.example/spring-sale?utm_source=newsletter&utm_medium="

    The & operator joins as text.

  10. C2"email"

    The value in C2.

  11. A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium="&C2"https://northwind.example/spring-sale?utm_source=newsletter&utm_medium=email"

    The & operator joins as text.

  12. A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium="&C2&"&utm_campaign=""https://northwind.example/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign="

    The & operator joins as text.

  13. D2"spring_2026"

    The value in D2.

  14. A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium="&C2&"&utm_campaign="&D2"https://northwind.example/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_2026"

    The & operator joins as text.

In Google Sheets

The same formula works in Google Sheets: =A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium="&C2&"&utm_campaign="&D2. We ran it in Google Sheets mode on the same data and it returns the same results.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&TEXTJOIN("&",TRUE,"utm_source="&B2,"utm_medium="&C2,"utm_campaign="&D2)https://northwind.example/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_2026, https://northwind.example/spring-sale?utm_source=facebook&utm_medium=paid_social&utm_campaign=spring_2026, https://northwind.example/chairs?color=oak&utm_source=google&utm_medium=cpc&utm_campaign=spring_2026…TEXTJOIN puts the & between the parameters for you, which is easier to extend with utm_term or utm_content.
=A2&"?utm_source="&B2&"&utm_medium="&C2&"&utm_campaign="&D2https://northwind.example/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_2026, https://northwind.example/spring-sale?utm_source=facebook&utm_medium=paid_social&utm_campaign=spring_2026, https://northwind.example/chairs?color=oak?utm_source=google&utm_medium=cpc&utm_campaign=spring_2026…Different resultThe simple version, fine when no base URL has a ? already. Row 4 gets a second ?, which breaks its link.

Common mistakes

  • Spaces in a campaign name break the link. Use underscores, or encode them with SUBSTITUTE(D2," ","%20") (Excel and Google Sheets also have ENCODEURL).
  • Analytics tools treat "Email" and "email" as different mediums. Wrap the values in LOWER to keep reports clean.

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Build UTM tracking links

In E2, build the tracking link: the base URL, then utm_source, utm_medium and utm_campaign from columns B to D. Use ? before the first parameter, or & if the URL already has a ?. Fill down to E6.

Questions

How do I make the link clickable?

Wrap it in HYPERLINK: =HYPERLINK(E2,"Open").

How do I add utm_content only when it is filled in?

Add it with IF: …&IF(F2="","","&utm_content="&F2).

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.