n8n + YOURLS: Create Short URLs, Unlock Stats, And Free Your Focus
Every time you manually shorten a link, paste it somewhere, then log in again later to check the stats, you lose a little bit of focus. It might only be a few seconds, but those seconds add up and break your flow.
Automation gives you those moments back. With n8n and YOURLS working together, you can turn a repetitive task into a one-click, fully tracked workflow. This template shows you how to shorten a URL and instantly pull its statistics, so you can stay focused on strategy, not busywork.
Think of this workflow as a small but powerful step toward a more automated, intentional workday. Once you see how easily you can automate link creation and analytics, you will start spotting other processes you can streamline too.
The Problem: Manual Link Management Slows You Down
If you share content regularly, you probably know the routine:
- Copy a long URL
- Open your URL shortener
- Create a short link
- Paste it into your social tool, email, or document
- Later, log back into your shortener to see how it performed
It works, but it is fragmented and easy to forget. Over time, that friction leads to:
- Missed tracking on some links
- Inconsistent analytics data
- Context switching that interrupts deep work
There is a better way. Instead of manually hopping between tools, you can let n8n and YOURLS handle the entire cycle for you: create the short URL, then immediately fetch click stats, all in one automated workflow.
The Possibility: A Mindset Shift Toward Automation
Automation is not just about saving a few clicks. It is about building systems that work for you, even when you are not paying attention. When you connect n8n with YOURLS, you are doing more than shortening links. You are designing a repeatable, reliable process that supports your marketing, reporting, and growth.
Once this workflow is in place, every new link you shorten can automatically:
- Generate analytics you can trust
- Feed dashboards and reports with consistent data
- Trigger notifications, storage, or follow-up actions
Instead of asking, “Did I remember to track that link?” you can ask, “What can I automate next?”
The Tool: An n8n + YOURLS Template That Does It For You
This n8n workflow template shows you how to:
- Shorten a long URL using your YOURLS instance
- Automatically pass the new short URL into a stats node
- Retrieve click data and other analytics instantly
It all runs through just three nodes, which makes it a perfect starting point if you are new to n8n or to automating YOURLS:
- Manual Trigger – kicks off the workflow when you click Execute in n8n
- YOURLS (shorten: url) – sends your long URL to YOURLS and returns the generated short URL
- YOURLS (stats: url) – takes that new short URL and fetches stats like clicks, referrers, and dates
From here, you can extend the workflow in any direction you want, from simple logging to full analytics pipelines.
Step 1: Prepare Your YOURLS Instance
Before n8n can help you automate, YOURLS needs to be ready to respond. Make sure you have:
- A working YOURLS installation or an existing instance, with an API endpoint such as https://short.example.com/
- An API token (signature), or a valid username and signature combination configured in YOURLS settings
This preparation is your foundation. Once YOURLS is reachable and secured, you can safely let n8n handle the repetitive calls.
Step 2: Connect YOURLS To n8n With Credentials
Next, you will teach n8n how to talk to YOURLS. This happens through credentials, which keep your secrets safe and reusable.
- In n8n, open Credentials > Add New > YOURLS
- Enter your YOURLS base URL and your API signature (or username and password if that is how your instance is configured)
- Save the credential so n8n can use it every time the workflow runs
Once this is set up, you will not need to re-enter these details. Your workflow can run repeatedly with secure, consistent access.
Step 3: Bring The Template Into n8n
Now you are ready to build the actual automation. You can either import the provided workflow JSON directly into n8n or recreate it manually. Both paths lead to the same result, so choose the one that feels most comfortable.
Core Nodes In The Workflow
- Manual Trigger A simple node that lets you test the workflow on demand. Click Execute in n8n, and the flow starts immediately.
- YOURLS (shorten) This node sends your long URL to YOURLS. Key parameters:
// Key parameters for the YOURLS shorten node
url: (the long URL you want to shorten)
additionalFields.title: (optional title for the link)
For example, you might set url to https://example.com/your-long-article and provide a descriptive title. YOURLS will return the short URL and related details.
- YOURLS (stats) This node reads the new short URL from the previous step and pulls analytics:
- Operation: stats
shortUrl: use an expression to pass the shortened URL from the YOURLS shorten node
The template uses this expression to capture the generated short link:
={{$node["Yourls"].json["shorturl"]}}
This tells n8n to look at the output of the YOURLS shorten node, read the shorturl property, and feed it into the stats node. With this link in place, the stats node can pull click counts, referrers, and more without any extra manual work.
What The YOURLS Nodes Return
Understanding the data that comes back from YOURLS helps you build smarter automations around it.
YOURLS Shorten Node Output
When you shorten a URL, YOURLS typically returns JSON with fields like:
url– the original long URLshorturl– the generated short identifier, such as abc123shorturl_fullorshort_link– the complete short link, including domain and identifiertitle– the title you provided for the link
YOURLS Stats Node Output
The stats node then returns analytics that you can feed into reports, dashboards, or notifications, including:
- Click counts, either total or per day
- Referrers that drove traffic to the link
- Geographic data when available
- Top dates for clicks
Sample Response Data
{ "url": "https://example.com/long-article", "shorturl": "abc123", "shorturl_full": "https://short.example.com/abc123", "title": "Long Article Title"
}
// Then the stats node can return:
{ "clicks_total": 42, "clicks_daily": {"2025-01-01": 10, "2025-01-02": 32}, "top_referrers": ["twitter.com", "example.com"]
}
With this structure in mind, you can easily map fields into Airtable, Google Sheets, dashboards, or any other tool you connect through n8n.
Real-World Ways To Use This Workflow
Once your first short URL and stats flow are working, you can plug it into the rest of your stack. Here are some practical scenarios where this template becomes a growth lever:
- Content publishing Automatically shorten blog post URLs when a new article goes live, then store click data in Airtable or a database for long-term reporting.
- Social media scheduling Integrate the workflow with your social scheduler so that every shared link is automatically shortened and tracked. Later, pull YOURLS stats to measure which posts perform best.
- Analytics dashboards Combine YOURLS stats with other analytics sources to build a unified dashboard that shows link performance alongside website metrics, campaigns, or email data.
Each of these use cases starts with the same simple building block: shorten a URL, grab the stats, and let n8n carry that data wherever it needs to go.
Troubleshooting: Turning Hiccups Into Learning Moments
As you experiment, you might hit a few snags. That is normal, and each issue you solve makes you more confident with n8n and YOURLS.
- Shorten node errors If the shorten node fails, double check your YOURLS base URL and API signature in the n8n credentials. A typo or outdated token is often the cause.
- Stats node cannot find the short URL Confirm the property name returned by your YOURLS version. It might use
shorturl,short_link, or another field. Use n8n’s Execution Data panel to inspect the returned JSON and update your expression accordingly. - CORS or connection issues If n8n cannot reach YOURLS, review your server firewall or hosting configuration and make sure the YOURLS endpoint is accessible from your n8n instance.
- Custom domain behavior When using custom domains, ensure YOURLS is configured to return the full short link if you prefer
shorturl_fullor similar fields instead of just the identifier.
Every fix you apply here will help you build more advanced workflows later with confidence.
Extending The Workflow: From Simple Shortcut To Analytics Engine
This template is intentionally lightweight so you can understand every step. But it is also a powerful starting point for more ambitious automation. Once it is working, try adding nodes to:
- Save short URLs and stats to Airtable, Google Sheets, or any relational database for long-term tracking
- Send a Slack message or email with the new short URL and initial stats so your team can act on it immediately
- Schedule periodic runs that revisit each short link and update click totals for your analytics dashboards
By layering these steps, you transform a one-off shortcut into a complete link analytics pipeline that runs without your constant attention.
Security And Privacy: Protecting What You Automate
YOURLS is often self-hosted, which means you keep control over your data and your short links. To keep that control strong as you automate:
- Treat your YOURLS API signature and credentials as sensitive secrets
- Store them in n8n credentials, not in plain text inside workflows
- Avoid exposing credentials in public workflows or shared screenshots
- Rotate your API signature or password if you suspect any leak
Good security practices help you scale your automation confidently, knowing your data and access are protected.
Before You Run: Quick Checklist
Use this short checklist to make sure everything is ready for a smooth first execution:
- Your YOURLS instance is online and reachable from your n8n environment
- YOURLS credentials are created in n8n and tested
- The YOURLS shorten node has the correct URL and optional title set
- The YOURLS stats node uses the correct expression to read the short URL from the previous node
Once these items are in place, you are ready to see the workflow in action.
Your Next Step: Run The Template And Build On It
Now it is time to move from idea to execution. Import the workflow JSON into n8n, plug in your YOURLS credentials, click Execute, and watch as your long URL turns into a tracked short link with stats returned instantly.
From there, challenge yourself to extend it. Add a Slack notification, push stats into Airtable, or schedule a recurring run that updates your dashboards daily. Each small improvement compounds, freeing more of your time for creative and strategic work.
If you are ready to keep building your automation skills, explore more n8n templates and tutorials, subscribe to our newsletter, or follow our blog for new step-by-step recipes every week. Each workflow you create is another step toward a more focused, automated, and scalable way of working.
