# How to build UTM tracking links in Excel

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

**Excel:** `=A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&"utm_source="&B2&"&utm_medium="&C2&"&utm_campaign="&D2` (Excel 2019 and later, including Microsoft 365)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E |
| --- | --- | --- | --- | --- |
| Base URL | Source | Medium | Campaign | Tracking link |
| https://northwind.example/spring-sale | newsletter | email | spring_2026 |  |
| https://northwind.example/spring-sale | facebook | paid_social | spring_2026 |  |
| https://northwind.example/chairs?color=oak | google | cpc | spring_2026 |  |
| https://northwind.example/desks | partner_blog | referral | desk_launch |  |
| https://northwind.example/ | linkedin | social | brand_q2 |  |

Formula in E2, filled to E6: `=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; 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; https://northwind.example/desks?utm_source=partner_blog&utm_medium=referral&utm_campaign=desk_launch; https://northwind.example/?utm_source=linkedin&utm_medium=social&utm_campaign=brand_q2

## 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.

## Other ways

- `=A2&IF(ISNUMBER(FIND("?",A2)),"&","?")&TEXTJOIN("&",TRUE,"utm_source="&B2,"utm_medium="&C2,"utm_campaign="&D2)`: 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="&D2`: The 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.

## 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)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/build-utm-tracking-links
