Skip to main content
info@drupalodyssey.com
Wednesday, June 24, 2026
Contact

Main navigation

  • Home
  • Services
  • Case Studies
  • Blog
  • Resources
  • About
Search
Development

Shortlink Manager: A Hitchhiker's Guide to Better Analytics

September 03, 2025

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 configuration
  • target_entity_type and target_entity_id — allowing a shortlink to point at any Drupal entity, automatically resolving its canonical URL
  • destination_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!

Photo by Ivan Samkov: https://www.pexels.com/photo/text-4491829/

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.

Read More
Photo by Negative Space: https://www.pexels.com/photo/blue-and-green-pie-chart-97080/

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.

Read More
Photo by Ramon Karolan: https://www.pexels.com/photo/orchestra-and-conductor-during-the-performance-13673492/

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.

Read More
https://www.pexels.com/photo/an-artist-s-illustration-of-artificial-intelligence-ai-this-image-was-inspired-neural-networks-used-in-deep-learning-it-was-created-by-novoto-studio-as-part-of-the-visualising-ai-proje-17483870/

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.

Read More
Man on a ladder changing a light bulb.

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.

Read More
A low-profile Art Deco "Grand Central" hub.

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.

Read More

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.

Author

Ron Ferguson

 

Next Blog

Ad - Header (728*90 AD)

Ad - Sidebar (300 x 600 AD)

Ad - Sidebar (300 x 250 AD)

Newsletter

Subscribe my Newsletter for new blog and tips.

Menu

  • Home
  • Services
  • Case Studies
  • Blog
  • Resources
  • About

Legal

  • Privacy Policy
  • Terms & Conditions
  • Disclaimer
  • Cookies

I specialize in custom development, performance tuning, and reliable maintenance, delivering clean code and strategic solutions that scale with your business. Ready to discuss your project?

E: info@drupalodyssey.com
Fort Worth, TX

© 2026 All Rights Reserved.

Proud supporter of active military, veterans and first responders.