How to Build UTM Links with an AI Agent
If you're using an AI agent to manage marketing campaigns, every link you publish should have UTM tracking. Without it, you can't attribute traffic in Google Analytics — and you're flying blind on what's actually driving results. Here's how to build properly tracked campaign links using an AI agent and MissingLinkz.
What are UTM parameters?
UTM parameters are tags you append to a URL so that Google Analytics (and other analytics platforms) can tell you exactly where your traffic came from. There are five standard parameters:
- utm_source
- Identifies which platform sent the traffic. Examples:
linkedin,twitter,newsletter,google. - utm_medium
- The marketing channel type. Examples:
social,email,cpc,referral. - utm_campaign
- The specific campaign name. Examples:
spring-launch,black-friday-2026,product-update-march. - utm_term
- Optional. Used for paid search to identify the keyword that triggered your ad. Example:
project+management+tool. - utm_content
- Optional. Differentiates between variations of the same ad or link. Example:
hero-ctavssidebar-banner.
A fully tagged URL looks like this:
https://yoursite.com/landing?utm_source=linkedin&utm_medium=social&utm_campaign=spring-launch
When someone clicks that link, Google Analytics records that the visit came from LinkedIn, via social media, as part of your spring-launch campaign. Without those tags, the visit shows up as "direct" or "unattributed" — making it impossible to know what's working. For a deeper look at why consistent naming matters, see our UTM naming convention guide.
The problem with manual UTM building
If you've ever built UTM links by hand — or worse, let every team member create their own — you've seen the mess that follows. The same source gets tagged three different ways: facebook vs Facebook vs fb. Google Analytics treats each as a separate source, fragmenting your data into useless silos.
It gets worse. According to industry research, 64% of companies have no formal UTM naming convention. The result? An estimated 22% of campaign attribution data is lost to inconsistencies, typos, and forgotten parameters. That's nearly a quarter of your marketing performance data — gone.
Manual UTM building also means nobody validates the destination URL. You tag a link to a page that 404s, or one that redirects through three hops and strips your UTM parameters along the way. You don't find out until the campaign is over and the analytics are a mess. Learn more about the real cost in our post on what broken campaign links actually cost you.
Step-by-step: Building UTM links with mlz preflight
Install MissingLinkz
Install the mlz CLI globally. Your AI agent can do this, or you can run it yourself. See the full setup guide for details on registration and configuration.
npm install -g missinglinkz
Requires Node.js 18 or later. The free tier gives you 50 links/month — no credit card required.
Run preflight on your campaign URL
The mlz preflight command does three things at once: builds your UTM-tagged URL, validates the destination, and inspects the landing page for issues. Here's a real example:
mlz preflight --url "https://yoursite.com/spring-sale" --campaign "spring-launch" --source "linkedin" --medium "social" --format human
The --format human flag gives you readable output instead of JSON. Agents parse JSON by default; humans get the pretty version.
Read the preflight results
The output tells you everything you need to know before publishing. Here's what it looks like:
ready: true
tracked_url: https://yoursite.com/spring-sale?utm_source=linkedin&utm_medium=social&utm_campaign=spring-launch
checks:
PASS og_tags All essential Open Graph tags present
PASS twitter_card Twitter Card tags configured
PASS viewport Viewport meta tag present
PASS ssl URL uses HTTPS
PASS resolution Destination responded with 200
PASS redirects No redirect chain detected
PASS response_time Page loaded in 380ms
PASS canonical Canonical URL matches destination
PASS favicon Favicon found
summary: 12 passed, 0 warnings, 0 failed
verdict: All checks passed. Ready to publish.
Here's what each part means:
- ready: true
- All checks passed. The link is safe to publish.
- tracked_url
- Your final campaign URL with UTM parameters appended. This is the link you share — copy it directly.
- og_tags / twitter_card
- Confirms the landing page has Open Graph and Twitter Card meta tags. Without these, your link shows up as a plain URL when shared on social platforms — no image, no title, no description.
- ssl
- The page is served over HTTPS. HTTP pages get flagged as "Not Secure" by browsers, killing trust.
- resolution
- The destination returned a 200 status code. This catches 404s, 500 errors, and dead servers before you send traffic to them.
- redirects
- No redirect chain detected. Long redirect chains slow page loads and can strip UTM parameters, breaking your attribution.
- response_time
- The page loaded in under 400ms. Every extra second of load time costs roughly 7% in conversions.
- canonical
- The page's canonical URL matches the destination. A mismatch splits your analytics data across two URLs.
If any check fails, preflight sets ready: false and tells you exactly what to fix. Your agent (or you) can address the issue and re-run. Read more about what each check catches in our campaign link preflight check guide.
Use the tracked URL
Copy the tracked_url from the output and use it wherever you're publishing — your LinkedIn post, tweet, email newsletter, or ad creative. That URL has your UTM parameters baked in, so every click is properly attributed in Google Analytics.
Multi-platform campaigns
Most campaigns run across multiple platforms at once. You need a unique tracked URL for each platform so Google Analytics can tell you which one drove the traffic. With mlz preflight, you run the command once per platform with a different --source (and optionally --medium) value.
Here's a spring launch campaign going out on LinkedIn, Twitter, and email:
mlz preflight --url "https://yoursite.com/spring-sale" --campaign "spring-launch" --source "linkedin" --medium "social"
tracked_url: https://yoursite.com/spring-sale?utm_source=linkedin&utm_medium=social&utm_campaign=spring-launch
mlz preflight --url "https://yoursite.com/spring-sale" --campaign "spring-launch" --source "twitter" --medium "social"
tracked_url: https://yoursite.com/spring-sale?utm_source=twitter&utm_medium=social&utm_campaign=spring-launch
mlz preflight --url "https://yoursite.com/spring-sale" --campaign "spring-launch" --source "newsletter" --medium "email"
tracked_url: https://yoursite.com/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring-launch
Each URL is unique. In Google Analytics, you'll see three separate rows under the spring-launch campaign — one for each source. No guessing, no manual spreadsheets, no naming inconsistencies. The landing page validation only runs once since it's the same destination; subsequent runs use the cached result. For a complete walkthrough on managing campaign links with AI agents, see our AI agent campaign links pillar page.
MCP integration for AI agents
If your AI agent supports Model Context Protocol (MCP) — like Claude Code, Cursor, or any MCP-compatible client — MissingLinkz can run as a local MCP server. This gives your agent direct, programmatic access to the same preflight functionality without shelling out to the CLI.
Start the MCP server:
mlz mcp
Then add this to your Claude Code MCP configuration (or equivalent for your agent):
{
"mcpServers": {
"missinglinkz": {
"command": "npx",
"args": ["-y", "missinglinkz", "mcp"]
}
}
}
Once connected, your agent can call the mlz_preflight tool directly. It accepts the same parameters — url, campaign, source, medium — and returns structured JSON with the tracked URL, check results, and pass/fail verdict. No CLI parsing required.
This means your agent can build UTM links, validate destinations, and inspect landing pages as part of its normal workflow — without you ever copying and pasting a command. It handles the entire process from campaign brief to publish-ready link.
For Agents
Give your AI agent the ability to build, validate, and track campaign links. Install MissingLinkz and run your first preflight check in under a minute.
npm install -g missinglinkz
mlz preflight --url "https://yoursite.com/landing" --campaign "spring-launch" --source "linkedin" --medium "social"
Read the full agent integration docs in SKILL.md — or explore the step-by-step human guide if you want to run commands yourself.