Every Drupal developer who runs a content site eventually faces the same problem: you write a post with a clean, SEO-friendly URL, and then you need to share it. Suddenly you're staring at something like https://example.com/blog/category/your-extremely-descriptive-post-title… and thinking there has to be a better way.
There is. But not from a third-party service that takes your data off-platform, locks you into their branding, and gives you no native integration with your Drupal content. I built the Shortlink Manager module because I needed something native — a solution with complete control over the data, the branding, and the workflow.
This series documents that build: every architectural decision, every feature addition, and every lesson learned along the way. If you're a Drupal developer who manages marketing campaigns, content distribution, or multi-channel tracking, this is the complete reference.
The module is open source: https://github.com/r0nn1ef/shortlink_manager
What the Shortlink Manager Does
At its core, the module turns a long URL into a short, trackable redirect path — /go/alsu9-m77t instead of the full campaign URL. But the architecture goes significantly further than that.
The key capabilities:
- Custom content entity for shortlinks with full Drupal field support
- UTM Sets — reusable campaign parameter templates that auto-apply to any shortlink
- Auto-generation of shortlinks when content is published
- Click analytics — per-click tracking with referrer, user agent, and timestamp data
- Intelligent expiration — links that retire themselves by date, click count, or inactivity
- QR code generation — downloadable PNG codes for offline-to-online campaigns
- Shortlink Block — a display widget that surfaces the shortlink for the current page
- Drush commands — full CLI management for power users and automation
- Feeds importer — bulk import shortlinks from CSV
The Architecture
The module is built around a non-fieldable content entity — Shortlink — that represents a single tracked redirect. This entity holds:
path— the unique slug (e.g., alsu9-m77t)utm_set— an entity reference to a reusable UTM Set configurationtarget_entity_typeandtarget_entity_id— allowing a shortlink to point at any Drupal entity, automatically resolving its canonical URLdestination_override— for external URLs or internal paths that aren't entities
The entity's resolveDestinationUrl() method handles the redirect logic: check for an override first, fall back to the entity's canonical URL if not. Campaign parameters are assembled from the associated UTM Set and appended automatically at redirect time.
Why a content entity and not config? Because shortlinks are data, not configuration. They need revision history, access control, and views integration — things you get for free with a content entity.
UTM Sets: Eliminating the Spreadsheet
The UTM Sets feature was the original forcing function for building this module. Before it existed, generating a tracked link meant opening a spreadsheet, manually combining the destination URL with utm_source, utm_medium, utm_campaign, utm_content, and utm_term for every social channel — every time. UTM Sets also allow you to add custom parameters for any custom metrics for your site!
Building a Custom Drupal Shortlink Manager: An SEO and Marketing Journey
Tired of manually managing long URLs and complex UTM parameters in a spreadsheet? So was I. This post is the first step in my journey to build a custom Drupal shortlink manager from scratch – a solution that's smarter, simpler, and completely integrated with Drupal.
How to Automate UTM Parameters with a Drupal Module
What if you could automate UTM parameters? This post shows you how I built a custom Drupal module to simplify Google Analytics tracking, transforming your shortlinks into powerful, data-rich tools.
Building a Smarter Shortlink: A Deep Dive into a Drupal Module
Tired of manually creating and tracking every shortlink? This post pulls back the curtain on how we built a smarter Drupal module to automate the process, exploring the code behind the content entity, controller, service, and auto-generation form that make it all work together.
Unleashing the Power of Shortlink Manager: From Bulk Imports to Extensibility
This final chapter on the Shortlink Manager module explores its most powerful features, from the user-facing Shortlink Block to the developer-focused Drush command and Feeds importer. The post highlights how these tools make the module a complete solution for modern digital marketers, developers, and content creators.
Unlock Dynamic UTMs: The Shortlink Manager Module Just Got Smarter
Automate your marketing attribution in Drupal. The Shortlink Manager module now supports dynamic Tokens for generating clean, contextual UTM parameters instantly. Stop typing, start tracking.
Shortlink Manager Evolved: Smarter Analytics, QR Codes, and AI-Driven Development
See how AI-driven development accelerated the move from a basic redirect tool to a full management suite. The new Beta release features high-performance click analytics, native QR code support, and automated broken link detection for both Drupal 10.5 and 11 environments.
Ready to Take Control of Your Shortlinks?
If this series has shown you the value and potential of the Shortlink Manager module, you can get started right away. This project is open-source and ready for you to explore on GitHub. You can download the module, contribute to its development, or simply check out the code. It's a strategic tool designed to help you succeed, and your feedback and collaboration are welcome.