---
title: "Configuring UTM Parameters and Campaign Tagging"
description: "Append Google Analytics UTM tracking parameters automatically and merge dynamic incoming query strings at the edge."
---

> Documentation Index
> Fetch the complete documentation index at: https://shaf.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring UTM Parameters and Campaign Tagging

# Configuring UTM Parameters and Campaign Tagging

Inconsistent query parameter formatting and manual tracking tag entry degrade marketing attribution across Google Analytics, Mixpanel, and customer data platforms. This guide configures automatic edge UTM parameter injection and query string forwarding while keeping public short link URLs clean.

---

## Prerequisites

- Workspace permissions: `Owner`, `Admin`, or `Member` role in your Shaf organization.
- Destination landing pages instrumented with an attribution script (Google Analytics 4, Mixpanel, Amplitude, Plausible).
- Established campaign naming taxonomy (`source`, `medium`, `campaign`).

---

## Implementation Recipe

1. **Define UTM Campaign Parameters**

   Configure the 5 standard Urchin Tracking Module parameters:

   | Parameter | Role | Recommended Values |
   | :- | :- | :- |
   | `utm_source` | Traffic origin platform | `newsletter`, `linkedin`, `twitter`, `google` |
   | `utm_medium` | Channel delivery format | `email`, `cpc`, `social`, `qr`, `referral` |
   | `utm_campaign` | Strategic campaign title | `q4_growth`, `spring_sale_2026`, `devcon` |
   | `utm_term` | Search keyword or audience | `cloud_links`, `devops_tools` |
   | `utm_content` | Creative variation or A/B test | `hero_banner`, `footer_cta`, `v2_video` |
2. **Attach UTM Tags to Short Links**

   Store UTM parameters alongside the link entity via API or Dashboard:

   ### cURL / API

   ```bash
   curl -X POST "https://shaf.app/api/v1/links" \
     -H "Authorization: Bearer $SHAF_API_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "url": "https://acme.com/pricing",
       "slug": "spring-pricing",
       "domain": "shaf.is",
       "utm": {
         "source": "newsletter",
         "medium": "email",
         "campaign": "spring_2026",
         "content": "cta_blue"
       },
       "tags": ["growth", "email", "q1-2026"]
     }'
   ```

   ### Dashboard

   1. Open the Link Editor.
   2. Select the **UTM Builder** tab.
   3. Fill in **Source**, **Medium**, and **Campaign**.
   4. Review the assembled destination preview.
   5. Assign organizational tags in the **Tags** field to bundle related campaign links.
   6. Click **Save Link**.
3. **Edge Query String Merging**

   When a visitor accesses a short link with dynamic query parameters (such as `user_id` or `click_id`), Shaf's edge runtime automatically combines them with your preconfigured UTM parameters:

   - **Incoming short URL**: `https://shaf.is/spring-pricing?ref=affiliate_123`
   - **Final resolved redirect**: `https://acme.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=spring_2026&utm_content=cta_blue&ref=affiliate_123`

---

## Verification

Probe redirect location headers to confirm parameter assembly:

```bash
curl -I "https://shaf.is/spring-pricing?customer_id=98765"
```

**Expected output:**
```http
HTTP/2 308 Permanent Redirect
location: https://acme.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=spring_2026&utm_content=cta_blue&customer_id=98765
x-shaf-utm: injected
x-shaf-edge: HIT
```

---

## Common Gotchas

| Issue / Error | Root Cause | Solution |
| :--- | :--- | :--- |
| Case sensitivity fractures in GA4 | Mixing capitalized and lowercase values (e.g. `Email` vs `email`). | Maintain a strict lowercase taxonomy across all UTM fields. |
| Parameter encoding errors | Raw spaces or ampersands entered in campaign names. | Shaf automatically percent-encodes strings (`spring sale` &rarr; `spring%20sale`). |
| Duplicate UTM parameter collisions | Incoming short link URL contains a `utm_source` that conflicts with the link template. | By default, incoming query parameters override static link templates. |
| Dropped query strings on fallback | Target destination redirected from `http` to `https`, stripping query tokens. | Always supply canonical `https://` destination URLs to avoid multi-hop redirect stripping. |

Source: https://shaf.app/docs/how-to/link-operations/utm-tags-and-campaigns/index.mdx
