# Campaign Link Checker: UTM tags, redirects and dead links (`examsens.ai/campaign-link-checker`) Actor

Paste an email's HTML before you send it. The actor requests each link and reports dead links, long redirect chains, missing UTM tags, http links and image links with no alt text. Unsubscribe, mailto, phone and merge token links are listed but not requested.

- **URL**: https://apify.com/examsens.ai/campaign-link-checker.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** SEO tools, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.90 / 1,000 link checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Campaign Link Checker: UTM tags, redirects and dead links

Paste the HTML of an email, or give it the address of a web page, and the actor lists every link in it. It sends a request to each web link's address, follows any redirects one hop at a time, and reads the status code the server answers with, so you see which links end on an error page instead of the page you meant. It also flags each link that's missing one of the UTM parameters, the `utm_source`, `utm_medium` and `utm_campaign` tags at the end of an address that your campaign reports read. Unsubscribe and preference links, `mailto:` and `tel:` links, and links holding a merge token are listed and never requested.

### Use it for

You're about to send a campaign email. Paste its HTML and read the rows marked broken first: each one shows the status the server answered and every hop on the way there. Then look for links flagged with missing UTM parameters. A link without them sends the visitor to your site with no campaign tags on the address.

After someone edits a template, run an email built from it and check the UTM flags again. Once a landing page or the web version of an email is live, give the actor its address instead, and it checks the links on the page as the server sends it.

### Sample

Input, an email with four links:

```json
{
  "html": "<html><body><p><a href=\"https://example.com/?utm_source=newsletter&utm_medium=email&utm_campaign=spring\">Read the guide</a></p><p><a href=\"https://example.com/pricing\">See pricing</a></p><p><a href=\"https://example.com/missing-page?utm_source=newsletter&utm_medium=email&utm_campaign=spring\">Old offer</a></p><p><a href=\"https://example.com/unsubscribe\">Unsubscribe</a></p></body></html>"
}
```

The run returned four link rows and one summary row. The pricing link answers 404 and carries none of the three UTM parameters. The old offer link answers 404 but has its UTM tags. The unsubscribe link is listed and not requested. Two of the rows, trimmed to the fields that matter here:

```json
[
  { "url": "https://example.com/pricing", "anchorText": "See pricing", "status": 404, "category": "clientError", "broken": true,
    "issues": ["answers 404", "missing UTM parameters: utm_source, utm_medium, utm_campaign"] },
  { "url": "https://example.com/unsubscribe", "anchorText": "Unsubscribe",
    "notes": ["matches a no request pattern, so it was listed and not requested"] }
]
```

The summary row: `linksFound` 4, `uniqueLinks` 4, `requested` 3, `broken` 2, `missingUtm` 1, `withIssues` 2.

### What it checks

Each unique link gets one row, with the number of times it appears and every anchor text used for it.

- A link is marked broken when the last answer is a 4xx or 5xx status other than 401, 403 and 429, when a redirect gives no destination, when the redirects loop back or run past the maximum, or when the request fails outright: the host name doesn't resolve, the certificate fails, the connection fails, or the address can't be read as a URL. A 401, 403 or 429 isn't marked broken, because a bot filter can answer that way for a link that works in a browser. A timeout isn't marked broken either. Either way, the row notes what came back.
- The row lists every redirect hop with its status. A chain of 3 hops or more is flagged, since each hop is one more request the reader's browser makes before the page opens. You can change that number.
- Every web link must carry each required UTM parameter with a value. The default list is `utm_source`, `utm_medium` and `utm_campaign`, and names match whatever their capital letters. Links that match your UTM skip patterns aren't checked for them.
- Links that use `http` instead of `https`, links with an empty or placeholder `href` such as `#`, `javascript:` links, links with no anchor text and image links whose image has no alt text are flagged. So is a relative link (one written without its domain) when you gave no base URL, since the actor can't tell which site it points to.
- A link holding a merge token such as `{{lead.First Name}}` or `[[name]]`, and a `mailto:` or `tel:` link, are listed and not requested. So is a link that matches a no request pattern. By default, both the no request patterns and the UTM skip patterns match any address containing `unsubscribe`, `opt-out`, `optout`, `opt_out` or `preference`, so the actor never opens a subscriber's unsubscribe or preference page.

### Input

- Email HTML, or page URLs, or both (at least one)
- Base URL for relative links in the HTML
- Required UTM parameters (default `utm_source`, `utm_medium`, `utm_campaign`). An empty list turns the UTM check off.
- No UTM check for links matching: regular expressions
- Do not request links matching: regular expressions
- Flag redirect chains of at least (default 3 hops), maximum redirects to follow (default 10)
- Maximum links per email or page (default 300), links checked at once (default 10), timeout per request (default 20 seconds)

### Output

One dataset row per unique link (`type: link`) and one summary row per email or page (`type: summary`).

A link row holds `url`, `kind` (`web`, `mailto`, `tel`, `placeholder`, `script`, `token` or `relative`), `anchorText`, `anchors`, `element`, `occurrences`, `status`, `category`, `broken`, `finalUrl`, `redirectCount`, `redirectChain`, `responseTimeMs`, `utm` (the UTM parameters found), `issues`, `issueCount`, `notes` and `error`.

The category is one of `ok`, `redirected`, `clientError`, `serverError`, `forbidden`, `rateLimited`, `timeout`, `redirectError`, `redirectLoop`, `dnsError`, `tlsError`, `connectionError` or `invalidUrl`.

The summary row holds `linksFound`, `uniqueLinks`, `requested`, `broken`, `missingUtm`, `httpLinks`, `longRedirectChains` and `withIssues`. A page that can't be read gets a summary row with `ok: false` and an `error`.

### Pricing

Pay per event: one event for each link requested. Links that are listed and not requested are not charged. The run stops when it reaches the maximum charge you set.

### Scope and conduct

For each link it checks, the actor sends one GET request, plus one more for every redirect hop. It reads the status and headers and closes the connection without reading the rest of the answer. A page you give by its address is downloaded in full, so its links can be read. The actor doesn't log in, fill in forms or collect personal data. It uses no proxies. Check links you're allowed to check.

### Related actors

From the same account, for checking a website:

- [Broken Link Checker: crawl a site, find dead links](https://apify.com/examsens.ai/broken-link-checker)
- [Site Audit: on page SEO and broken link checks](https://apify.com/examsens.ai/site-audit)
- [Domain DNS and Email Check: SPF, DMARC, DKIM, MX and SSL](https://apify.com/examsens.ai/domain-dns-check)

### Support

Questions and problems: the Issues tab on this page.

# Actor input Schema

## `html` (type: `string`):

The HTML source of an email or page. Every link in it is listed and checked.

## `baseUrl` (type: `string`):

Used to resolve links such as /pricing in the HTML above. Leave empty when every link is a full address.

## `urls` (type: `array`):

Web pages to read the links from, for example the web version of an email. Each page is read once and its links are checked.

## `requiredUtmParams` (type: `array`):

Every web link must carry each of these query parameters with a value. Names are matched without regard to case. Use an empty list to turn the UTM check off.

## `skipUtmPatterns` (type: `array`):

Regular expressions. A link that matches one is not checked for UTM parameters. Defaults to unsubscribe and preference links.

## `skipRequestPatterns` (type: `array`):

Regular expressions. A link that matches one is listed but never opened, and is not charged. Defaults to unsubscribe and preference links, because opening one can change a subscriber's status.

## `longRedirectChain` (type: `integer`):

A link that passes through this many redirects or more is flagged.

## `maxRedirects` (type: `integer`):

A link with more redirects than this is reported as a redirect error.

## `maxLinks` (type: `integer`):

Unique links beyond this number are left out.

## `maxConcurrency` (type: `integer`):

How many links are requested in parallel.

## `timeoutSecs` (type: `integer`):

A request that gets no answer in this time is reported as a timeout.

## Actor input object example

```json
{
  "html": "<html><body><p><a href=\"https://example.com/?utm_source=newsletter&utm_medium=email&utm_campaign=spring\">Read the guide</a></p><p><a href=\"https://example.com/pricing\">See pricing</a></p><p><a href=\"https://example.com/missing-page?utm_source=newsletter&utm_medium=email&utm_campaign=spring\">Old offer</a></p><p><a href=\"https://example.com/unsubscribe\">Unsubscribe</a></p></body></html>",
  "requiredUtmParams": [
    "utm_source",
    "utm_medium",
    "utm_campaign"
  ],
  "skipUtmPatterns": [
    "unsubscribe",
    "opt-out",
    "optout",
    "opt_out",
    "preference"
  ],
  "skipRequestPatterns": [
    "unsubscribe",
    "opt-out",
    "optout",
    "opt_out",
    "preference"
  ],
  "longRedirectChain": 3,
  "maxRedirects": 10,
  "maxLinks": 300,
  "maxConcurrency": 10,
  "timeoutSecs": 20
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "html": "<html><body><p><a href=\"https://example.com/?utm_source=newsletter&utm_medium=email&utm_campaign=spring\">Read the guide</a></p><p><a href=\"https://example.com/pricing\">See pricing</a></p><p><a href=\"https://example.com/missing-page?utm_source=newsletter&utm_medium=email&utm_campaign=spring\">Old offer</a></p><p><a href=\"https://example.com/unsubscribe\">Unsubscribe</a></p></body></html>"
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/campaign-link-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "html": "<html><body><p><a href=\"https://example.com/?utm_source=newsletter&utm_medium=email&utm_campaign=spring\">Read the guide</a></p><p><a href=\"https://example.com/pricing\">See pricing</a></p><p><a href=\"https://example.com/missing-page?utm_source=newsletter&utm_medium=email&utm_campaign=spring\">Old offer</a></p><p><a href=\"https://example.com/unsubscribe\">Unsubscribe</a></p></body></html>" }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/campaign-link-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "html": "<html><body><p><a href=\\"https://example.com/?utm_source=newsletter&utm_medium=email&utm_campaign=spring\\">Read the guide</a></p><p><a href=\\"https://example.com/pricing\\">See pricing</a></p><p><a href=\\"https://example.com/missing-page?utm_source=newsletter&utm_medium=email&utm_campaign=spring\\">Old offer</a></p><p><a href=\\"https://example.com/unsubscribe\\">Unsubscribe</a></p></body></html>"
}' |
apify call examsens.ai/campaign-link-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,examsens.ai/campaign-link-checker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/FR4hjH9VjoetSpTVU/builds/6JgIHuTNaNEnzKuaC/openapi.json
