You can build a fully functional URL shortener using just Apps Script and Google Sheets — no domain, no server, no cost. The Web App handles redirects, the Sheet stores the mappings.
Sheet structure
Create a sheet named Links with these columns:
| A: Short Code | B: Long URL | C: Created At | D: Click Count |
The Web App script
functiondoGet(e){const code = e.parameter.c;if(!code){returnHtmlService.createHtmlOutput('<h2>URL Shortener</h2><p>No code provided.</p>');}const sheet =SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Links');const data = sheet.getDataRange().getValues();for(let i =1; i < data.length; i++){if(data[i][0]=== code){const longUrl = data[i][1];// Increment click count sheet.getRange(i +1,4).setValue((data[i][3]||0)+1);// RedirectreturnHtmlService.createHtmlOutput(`<script>window.location.href = "${longUrl}";</script>
<p>Redirecting... <a href="${longUrl}">Click here if not redirected</a></p>`);}}returnHtmlService.createHtmlOutput('<h2>404 — Short link not found.</h2>');}