I built my own QR code system on Cloudflare (and you probably should too)
Short version: I've built my own QR code and short link system on qr.dergal.co.uk, running on Cloudflare. It handles the redirects, counts every scan, makes the QR codes (and NFC links), and checks once a week that nothing it points at has broken. It costs nothing to run, and because it sits on my own domain, no QR company gets to decide where my printed codes end up.
I put QR codes on quite a few things: slides at conferences, business cards, event bits and pieces. Like most people, I'd been using whichever generator came up first in Google. It's fine until you stop and think about what happens to those codes in two years' time, and this week Xerox gave everyone a very good reason to think about it (more on that below).
So I built my own. This is what it does, what caught me out, and what it costs.
What I built
I wanted short links on my own domain, a QR code for each one, and some idea of whether anyone actually scans them. It took an afternoon. The setup is roughly:
- Someone scans a code pointing at qr.dergal.co.uk/something.
- A Cloudflare Worker (a small bit of code that runs on Cloudflare's network) looks "something" up in a D1 database and sends them on to wherever that link points today.
- On the way past it logs the scan: time, rough location, device, browser, and whether it came from a QR code, an NFC tag or a plain link. It doesn't store IP addresses, and it ignores bots.
- The admin sits on a separate subdomain behind Cloudflare Access, so the only way in is my login.
The dashboard, here with made-up data so I'm not sharing my own numbers.
From the admin I can create a link and download its QR code as an SVG for print or a PNG for screens, with my logo in the middle if I want it. I can change where a link goes whenever I like, pause it, or download a zip of every code with a given tag for the printer. Each link also has an NFC version, because I fancy putting a few tags on things, and taps get counted separately from scans.
Every link gets a QR code, with or without a logo.
The feature I'm happiest with is the dullest one. Once a week it checks every destination, and anything returning a 404 or a server error shows up in red. Printed codes tend to outlive the pages they point at, usually because someone rebuilt the website, and I'd rather find that out before a customer does.
An old workshop flyer pointing at a page that no longer exists.
Why not just use a QR code generator?
Most "dynamic" QR codes, the ones you can edit after printing, don't point at your website at all. They point at the generator's own short link, which then forwards to you. That's how you get to change the destination later, and it's also how they hold you to the subscription. Uniqode's own guide is pretty upfront that one missed renewal can switch off every dynamic code on an account at once, that free plans can cap you at 50 or 100 scans a month, and that if the provider shuts down or gets bought, the codes go with it.
Think about where QR codes end up. Menus, packaging, shop windows, the back of business cards, conference slides that live online forever. The subscription is cheap. Reprinting isn't. And whoever scans a dead code doesn't blame the QR company, they blame you.
Even owning the domain only helps if you hang on to it, which is where Xerox comes in. BleepingComputer reported on 1 December that Xerox is replacing QR code labels on printers across the UK. The labels came from Arena Group, which Xerox bought in 2020, and pointed at an Arena support domain. That domain was left to expire, someone else registered it in October, and now the codes lead to an adult site. Nobody hacked anything. The stickers are just doing what they were printed to do. Heinz had almost exactly the same problem with ketchup bottles in Germany back in 2015.
"But Gerry, you've built yours on Cloudflare"
Yes, I know. Telling people not to rely on third parties and then building the whole thing on Cloudflare isn't lost on me.
The difference is the domain. Every code I print points at qr.dergal.co.uk, which is mine. Cloudflare runs the bit that does the redirecting, but it doesn't own the link. If Cloudflare tripled its prices tomorrow, I could rebuild the redirects somewhere else in a few days, point the DNS at the new setup, and every code I've ever printed would keep working. Nobody scanning one would know anything had changed.
What caught me out
A few things I didn't expect, in case you try this yourself:
- LinkedIn doesn't like being checked. It sends automated requests a status code of 999, which isn't even a real HTTP status. My link checker now treats that, along with 403s and 429s, as "can't verify" rather than broken, otherwise my LinkedIn link would be permanently red.
- Location data is rough. My first test scan, from London, was logged as Chelmsford. City-level location from an IP address is a best guess, so I treat country as reliable and city as a vibe.
- Cloudflare can get in its own way. I tried serving the screenshots for this post from the same subdomain, and anything ending in .png got grabbed by Cloudflare's image handling before it reached my code. Dropping the file extension fixed it. No idea why I expected that to be simple.
What does it cost?
Nothing so far, and probably nothing for a long time. Each scan is one request to the Worker and one row written to the database. Cloudflare's free plan allows 100,000 of each a day, which is around 3 million scans a month.
The free limits reset at midnight UTC. Go over the request limit and redirects stop working until then, so if you're about to put a code on national packaging or a TV ad, pay the $5. Go over the database limit and you only lose the tracking, because the click is saved after the person has already been sent on their way. The limit you're most likely to notice first is actually the dashboard, since every view reads back through the stored clicks. That only bites once you've got hundreds of thousands of scans stored.
Where could you take it?
Once every scan goes through code you control, you can start making decisions with it. Mine already sends people to different places depending on their phone, their country or the date. So an iPhone can go to the App Store and an Android phone to Google Play, someone in Ireland can land on euro pricing, and the code on a conference flyer can switch from the agenda to the recordings the morning after the event.
Three rules on one link: iPhones, visitors from Ireland, and anyone scanning after the event.
The obvious next step is split testing, sending half the scans to one page and half to another. That's where it gets interesting for anyone who prints a lot:
- A meal kit company could test whether the QR code on a recipe card works better pointing at a video or at written steps, and measure it in reorders rather than clicks.
- A restaurant could change what the table QR code shows depending on whether it's lunch or dinner, without reprinting anything.
- An estate agent could test whether a for sale board does better sending people to the listing or straight to booking a viewing.
- An author could test the back page of a book: next book in the series, or newsletter sign-up?
Add UTM parameters to each destination and the scans show up properly in GA4 too. If you want to catch the people who bounce before your analytics tag fires, the Worker can send the scan to GA4 server-side as well.
Before you print another QR code
Even if you never build anything like this, it's worth checking a few things:
- Does the code point at a domain you actually own? If it points at a QR generator's domain, you're renting it.
- Will you still own that domain for as long as the printed thing exists? Campaign microsites and domains that came with an acquisition are the ones that get forgotten.
- Is it on auto-renew, with a card that won't expire and renewal emails going to someone who still works there?
- When a campaign finishes, does the link redirect somewhere sensible?
- Is anyone checking, now and again, that each printed code still lands on a working page?
If you want a hand setting up something like this, or checking what's out there with your name on it, give me a shout. I'm always happy to chat about this sort of thing.
Sources
- Xerox replacing UK printer QR labels after old domain serves porn, BleepingComputer, 1 December 2026
- Heinz QR code leads customer to porn, or why you should hold on to your domains, The Next Web, 18 June 2015
- Do QR codes expire?, Uniqode
- Workers pricing and D1 pricing, Cloudflare docs, checked 1 December 2026









