Black Friday 40% off yearly and lifetime plans · 18d left Ends in 18d09h24m Claim 40% off
Core42 docs

How to Create Short Links with Click Tracking in WordPress

Create branded short URLs with click tracking in Classic Monks. Built-in short link manager with expiration, password protection, and analytics.

By Founder & Lead Developer

Last updated

4 minutes

Key takeaways

  • Create branded short URLs like yoursite.com/go/offer without external services
  • Track clicks with geographic, device, and referrer data
  • Set expiration dates and password protection for time-sensitive campaigns

Why You Need It

When you share links on social media, email campaigns, or printed materials, long URLs look unprofessional and break across lines. Third-party shorteners solve this but introduce problems: you depend on their uptime, they add a redirect hop that slows your site, and you lose control of your data.

Classic Monks gives you self-hosted short links that are fast, branded, and fully tracked. Your links stay on your domain, load faster without third-party redirects, and all analytics stay in your WordPress database.

How to View Click Analytics

  1. Step 1

    Open Short Links

    Click Classic Monks > Short Links in the admin sidebar.

  2. Step 2

    Select a Link

    Click on any short link to view its analytics dashboard.

  3. Step 3

    Review the Data

    You’ll see:

    • Total Clicks: Aggregate click count over time
    • Clicks Over Time: A chart showing click trends (daily, weekly, monthly)
    • Geographic Data: Where your clicks are coming from (country, city)
    • Device Data: Desktop, mobile, or tablet breakdown
    • Referrer Data: Which sites or campaigns are driving clicks

Configuration Options

Option Description Default
Title Internal reference name for the link Required
Target URL Full destination URL Required
Short Slug Custom path segment Auto-generated
Expiration Date Date when the link stops redirecting None
Password Require a password to access the link None
Active/Inactive Enable or disable the redirect Active

Advanced Options (Developers)

Programmatic Link Creation

Create short links via the REST API:

// Create a short link programmatically
$link = wp_insert_post([
    'post_type'   => 'cm_short_link',
    'post_status' => 'publish',
    'post_title'  => 'My Campaign',
    'meta_input'  => [
        'cm_short_link_target'     => 'https://yoursite.com/destination',
        'cm_short_link_slug'       => 'go/campaign',
        'cm_short_link_expiry'     => '2026-12-31',
        'cm_short_link_password'   => '',
    ],
]);

Filter Click Data

Access click analytics programmatically:

// Get click count for a specific link
$click_count = get_post_meta($link_id, 'cm_short_link_clicks', true);

// Get geographic data
$geo_data = get_post_meta($link_id, 'cm_short_link_geo_data', true);

Custom Redirect Logic

Add custom logic before the redirect fires:

// Redirect mobile users to a different URL
add_action('cm_short_link_redirect', function($link_id, $target_url) {
    if (wp_is_mobile()) {
        $mobile_url = get_post_meta($link_id, 'cm_short_link_mobile_target', true);
        if ($mobile_url) {
            wp_redirect($mobile_url);
            exit;
        }
    }
}, 10, 2);

Troubleshooting

3 problems and how to fix each one.

Short Link Shows 404

Cause: The slug conflicts with an existing WordPress rewrite rule, or permalinks need to be flushed.
Fix: Go to Settings > Permalinks and click Save Changes to flush rewrite rules. Choose a unique slug that doesn’t conflict with existing pages or posts.

Click Count Not Updating

Cause: Page caching is serving a cached version that skips the click tracking.
Fix: Exclude short link URLs from your caching plugin, or add a no-cache header for the redirect endpoint. If using a CDN, purge the cache after creating new links.

Password Protection Not Working

Cause: The password form isn’t rendering due to a theme or plugin conflict.
Fix: Check that your theme isn’t overriding the password form template. Try switching to a default theme temporarily to isolate the issue.

Was this doc helpful?

Your answer tells us which docs to fix first.

Still stuck? Ask on the forum or email help@classicmonks.com.
Joy Chetry
Written by the person who built it

Joy Chetry

Founder & Lead Developer, Classic Monks

Joy is the founder of Classic Monks and GoodMonks Solutions, a web development agency that builds WordPress and WooCommerce sites for clients. Classic Monks grew out of the agency's own need to consolidate 20 to 30 separate plugins into one core stack.

Follow this doc on a real site.

Open a private WordPress site with Classic Monks, WooCommerce and Bricks Builder installed, and follow this doc step by step. Free for 24 hours, no card.

280 docs, written by Joy Chetry 15 day refund window