Adds a UTM links collection to Payload where editors generate campaign URLs live, copy them, and keep a searchable inventory. The plugin registers via the plugins array and needs Payload 3.92 or newer. It supports source and medium presets, an optional origin allowlist, value normalization, and authenticated CSV export. It does not track clicks or retrieve analytics data.
Campaign links, live UTM generation, presets and access-controlled CSV exports for Payload CMS 3.
Installation
npm i payload-plugin-utm1
Stars
0
Forks
2
Open Issues
2 weeks ago
Last Updated
68
Weekly Downloads
v0.1.1
npm Version
307.3 KB
Unpacked Size
0
Dependencies
1+1 since Nov 1
| Date | Stars |
|---|---|
| Dec 6, 2026 | 1 |
| Dec 5, 2026 | 1 |
| Dec 4, 2026 | 1 |
| Dec 3, 2026 | 1 |
| Dec 2, 2026 | 1 |
| Dec 1, 2026 | 1 |
| Nov 30, 2026 | 1 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 1 |
| Nov 25, 2026 | 1 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 1 |
| Nov 22, 2026 | 1 |
| Nov 21, 2026 | 1 |
| Nov 20, 2026 | 1 |
| Nov 19, 2026 | 1 |
| Nov 18, 2026 | 1 |
| Nov 17, 2026 | 1 |
| Nov 16, 2026 | 1 |
| Nov 15, 2026 | 1 |
| Nov 14, 2026 | 1 |
| Nov 13, 2026 | 1 |
| Nov 12, 2026 | 1 |
| Nov 11, 2026 | 1 |
| Nov 10, 2026 | 0 |
| Nov 9, 2026 | 0 |
| Nov 8, 2026 | 0 |
| Nov 7, 2026 | 0 |
| Nov 6, 2026 | 0 |
| Nov 5, 2026 | 0 |
| Nov 4, 2026 | 0 |
| Nov 3, 2026 | 0 |
| Nov 2, 2026 | 0 |
| Nov 1, 2026 | 0 |
69+69 since Nov 16
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 69 |
| Dec 5, 2026 | 52 |
| Dec 4, 2026 | 47 |
| Dec 3, 2026 | 55 |
| Dec 2, 2026 | 75 |
| Dec 1, 2026 | 76 |
| Nov 30, 2026 | 95 |
| Nov 29, 2026 | 90 |
| Nov 28, 2026 | 105 |
| Nov 27, 2026 | 200 |
| Nov 26, 2026 | 249 |
| Nov 25, 2026 | 394 |
| Nov 24, 2026 | 733 |
| Nov 23, 2026 | 1,705 |
| Nov 22, 2026 | 1,687 |
| Nov 21, 2026 | 1,671 |
| Nov 20, 2026 | 1,574 |
| Nov 19, 2026 | 1,510 |
| Nov 18, 2026 | 1,343 |
| Nov 17, 2026 | 991 |
| Nov 16, 2026 | 0 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1443199925-root)<a href="https://payloaddirectory.dev/plugins/1443199925-root"><img src="https://payloaddirectory.dev/badge/1443199925-root.svg" alt="Payload Directory"></a>README
Create campaign links where your content already lives: in Payload CMS.
Live URL generation, one-click copy, reusable source/medium presets, a searchable campaign inventory and permission-aware CSV exports. No analytics account, redirect service or external API required.
Community plugin · MIT · Payload 3.92+ · React 19 · Node 22+
pnpm add payload-plugin-utm
Also works with npm install or yarn add. A 0.2 beta that adds opt-in page personalization by campaign audience and statistics is available with pnpm add payload-plugin-utm@beta; the default install stays on this stable line.
Add the plugin to your existing Payload configuration:
import { buildConfig } from 'payload'
import { utmPlugin } from 'payload-plugin-utm'
export default buildConfig({
// Keep your database, auth collection, editor and other app settings.
plugins: [
utmPlugin({
presets: [
{ label: 'Newsletter', source: 'newsletter', medium: 'email' },
{ label: 'Instagram story', source: 'instagram', medium: 'social', content: 'story' },
],
}),
],
})
Then run your normal payload generate:importmap, payload generate:types and database migration workflow. Generate migrations in your application: this plugin does not ship database-specific migrations.
The three required parameters are utm_source, utm_medium and utm_campaign. Optional fields support utm_id, utm_content and utm_term. Existing non-UTM query parameters and fragments are preserved. Old UTM parameters, including duplicates and mixed-case keys, are replaced.
The server always recalculates the saved URL. API clients cannot substitute a forged generatedUrl; partial updates preserve existing campaign parameters.
| Option | Default | What it does |
|---|---|---|
enabled | true | Disable the plugin without changing the app config. |
collectionSlug | 'utm-links' | Rename the collection. A conflicting slug throws a startup error. |
relatedCollections | none | Add an optional relationship to your content collections. It does not replace the destination URL. |
presets | [] | Quick-fill buttons: { label, source, medium, content? }. |
locale | 'en' | English or French text for custom controls. Field labels support both through Payload's admin language. |
allowedOrigins | unrestricted | Optional exact origin allowlist, e.g. ['https://example.com']. An empty list denies all destinations. No paths, wildcards or trailing slashes. |
normalization | 'preserve' | Preserve case, lowercase values, or produce ASCII slugs with 'slug'. Trims outer whitespace in every mode. |
csvExport | enabled, 1000 rows | false disables it. { maxRows: 5000 } sets a cap between 1 and 10000. Oversized exports return HTTP 413 rather than silently truncating. |
overrides | none | A function receiving and returning the generated CollectionConfig. Customize access, labels, fields, hooks and endpoints. Change the slug through collectionSlug. |
UTM values are case-sensitive in downstream tools. No lowercasing happens by default. Slug normalization removes non-ASCII characters; do not use it for campaigns whose names must retain non-Latin text. Required values that normalize to an empty string fail validation. Parameter values are limited to 512 characters; destination URLs to 8192.
Install the UTM plugin before Payload's multi-tenant plugin so the latter can add its tenant field, access rules and filters:
import { multiTenantPlugin } from '@payloadcms/plugin-multi-tenant'
plugins: [
utmPlugin({ relatedCollections: ['pages', 'posts'] }),
multiTenantPlugin({
collections: { 'utm-links': {} },
// Keep your normal tenant configuration.
}),
]
The plugin itself is tenant-agnostic. There are no hardcoded collection names, tenants, domains or user roles. Include your normal tenant field when creating links through the API. Changing a collection slug or an existing app's normalization policy needs an application migration/data review.
All CRUD operations require req.user by default. Supply your own role checks through overrides:
utmPlugin({
overrides: (collection) => ({
...collection,
access: {
...collection.access,
delete: ({ req }) => Boolean(req.user?.roles?.includes('admin')),
},
}),
})
Adapt the example to your generated user type. The CSV endpoint always requires authentication and runs with overrideAccess: false, forwarding the original request. Collection, field and multi-tenant access rules still apply. Application hooks run before the final URL calculation. If you replace core fields or add a beforeChange hook, you are responsible for maintaining the plugin's invariants.
Download from the link editor, or request:
GET /api/utm-links/export-csv
GET /api/utm-links/export-csv?where[campaign][equals]=summer-launch
GET /api/utm-links/export-csv?where[tenant][equals]=123
Use your normal authenticated Payload session/API credentials and your app's API prefix. The editor download includes all saved records the current user can read, not just the current document or an implicit list-view selection. Add where filters to scope a campaign or tenant. Exported fields are fixed campaign metadata; internal notes and related document contents are not exported. Fields denied by field-level access appear empty.
CSV uses UTF-8 with a BOM, CRLF line endings and quoted cells. Values that could be interpreted as spreadsheet formulas are prefixed with an apostrophe. Responses are private and not cached. Archiving organizes the inventory: it does not deactivate links that have already been shared.
The utilities entry point has no runtime dependencies and can be used in scripts or other frameworks:
import { buildUtmUrl, buildUtmVariants } from 'payload-plugin-utm/utilities'
const base = {
destination: 'https://example.com/article/?ref=menu#details',
source: 'instagram',
medium: 'social',
campaign: 'summer-launch',
}
buildUtmUrl(base)
// https://example.com/article/?ref=menu&utm_source=instagram&utm_medium=social&utm_campaign=summer-launch#details
buildUtmVariants(base, [
{ content: 'bio' },
{ source: 'newsletter', medium: 'email', content: 'button' },
])
buildUtmUrl returns null for invalid/incomplete input. buildUtmVariants throws with the 1-based index of an invalid variant; it never writes to your database. validateDestination, normalizeUtmValue, utmLinksToCsv and utmParameters are also exported.
This is a link-management plugin, not an attribution platform. It does not record clicks, inject tracking scripts, proxy/shorten URLs, collect visitors, or retrieve GA4 statistics. Direct campaign links work independently of Payload after you copy them. Whether a destination records UTM traffic depends on that site's analytics setup.
Tested with Payload/UI 3.92.0 and React 19.2.6. CI tests the package on Node 22 and 24. A Postgres/Next.js consumer build is also verified during initial release validation; broader database/browser compatibility should be verified in your app before rollout. Use Payload and @payloadcms/ui versions that match each other.
corepack enable
pnpm install --frozen-lockfile
pnpm check
pnpm pack
See CONTRIBUTING.md, SECURITY.md, CHANGELOG.md and ROADMAP.md. PRs improving accessibility, translations, adapters and test coverage are welcome.
payload plugin analytics
GA4-backed analytics dashboard in the Payload admin with a client-side tracking layer for Next.js front ends
70821/wk37v3
payload posthog
Native PostHog integration for Payload Admin covering analytics, session replay, error tracking, logs and feature flags
791.7k/wk0v3
analytics
Analytics Settings global for Google tags, custom scripts, pixels and UTM cookies on Next.js sites, with consent…
77627/wk0v4
payload plugin ab
A/B testing with page variants managed in the Payload admin and routed by Next.js middleware at the edge
741.0k/wk37v3
payload plugin stats
Privacy-preserving user count statistics for the Payload admin, with small groups hidden
7380/wk0v3
tracking
Tracking global and React providers for PostHog, Google Tag Manager and Vercel Analytics
6132/wk37v3