i created a n8n agent to track click count of urls
This project contains two connected n8n workflows for automating the generation of redirect URLs + QR codes for YouTube videos, and for tracking QR scans and click counts in Google Sheets.
urlcreatorworkflow → Reads YouTube links from a Google Sheet, normalizes them, and generates redirect URLs & QR codes.finalcloudworkflow → Handles incoming QR scans via a webhook, redirects to the correct YouTube video, and logs click count & metadata (IP, user-agent, timestamp) back to Google Sheets.
These workflows enable you to:
- Automate YouTube link cleanup & normalization (handling
youtu.be,shorts,watch?v=, and playlists). - Generate redirect URLs that funnel clicks through a tracking webhook.
- Create QR codes for each video link.
- Track clicks, user agent, IP, timestamp, and total scan counts in Google Sheets.
Perfect for campaigns, classrooms, or organizations where you need to distribute scannable video links while collecting analytics.
- Trigger: Manual Trigger
- Steps:
- Read All Videos → Fetch rows from Google Sheets (
Videos!A1:H999). - Generate URLs →
- Normalize YouTube URLs.
- Generate redirect URL pointing to the webhook.
- Generate a QR code using
api.qrserver.com.
- Update Videos Sheet → Write
Redirect URLandQR Code URLback to Google Sheets.
- Read All Videos → Fetch rows from Google Sheets (
✅ Skips headers & empty rows.
✅ Handles multiple YouTube URL formats.
- Trigger: Webhook (
/track-scan). - Steps:
- Process Click Data → Extract
id,target, user-agent, IP. - Redirect to YouTube → Sends user to the final YouTube link.
- Log to Google Sheets → Append click event details.
- Get Existing Row → Find the video by
ID. - Increment Count → Increase
Click Countfor that video. - Update Click Count → Save back into the sheet.
- Process Click Data → Extract
✅ Stores timestamp, date, time, user agent, and IP.
✅ Increments click count on each scan.
- Install n8n.
- Import both JSON workflows into n8n:
urlcreator_final.jsonfinalcloud_final.json
- Set up Google Sheets credentials in n8n.
- Configure your Google Sheet with the correct structure (see below).
- Deploy the workflows (ensure
finalcloudwebhook is active).
- Populate Google Sheets with video IDs & YouTube URLs.
- Run
urlcreatorworkflow → Fills sheet with redirect & QR code links. - Share the QR codes publicly.
- When users scan,
finalcloudworkflow:- Redirects them to the YouTube video.
- Logs the scan details.
- Increments the click counter.
This project is open source under the MIT License.