How to Shorten a URL in Google Sheets: Automation Guide
Google Sheets is where a large proportion of marketing link management actually happens — campaign URL lists, content calendars, product catalogues, affiliate link inventories, and outreach tracking spreadsheets all live in Sheets. The natural next step is shortening those URLs directly inside the spreadsheet — creating a short link for each row without leaving the sheet, copying and pasting between tools, or manually creating hundreds of links one by one in a dashboard. There are four realistic approaches to shortening URLs in Google Sheets, ranging from a simple formula-style custom function to a no-code automation via Zapier or Make. This guide covers all four in practical detail: when to use each, how to set it up, and the complete code for the Apps Script approach that most teams will want to use.
What This Guide Covers
- Four approaches compared — which to use when
- Method 1: Google Apps Script custom function — the recommended approach
- Complete Apps Script code with error handling
- Adding branded domains and custom aliases from sheet columns
- Adding UTM parameters from sheet columns
- Running the script on an entire column in bulk
- Method 2: IMPORTDATA formula — quick but limited
- Method 3: Zapier or Make — no-code, triggered automation
- Method 4: Manual workflow — Cuttly CSV export and import
- Setting up a sheet template for campaign link management
- Which Cuttly plan to use
Four Approaches Compared
Before diving into setup, it helps to understand the trade-offs between the four available methods. The right choice depends on your technical comfort level, how frequently links need to be created, and whether you need branded domains or custom aliases.
| Method | Technical requirement | Custom alias? | Branded domain? | Best for |
|---|---|---|---|---|
| Apps Script custom function | Basic JavaScript (copy-paste) | Yes | Yes | Teams running regular campaigns from Sheets — most versatile |
| IMPORTDATA formula | No code — formula only | No | No (cutt.ly only) | Quick one-off shortening without full setup |
| Zapier / Make automation | No-code — visual workflow | Yes (mapped) | Yes | Always-on automation triggered by new rows |
| Manual + CSV export/import | None | Yes (prepared in CSV) | Yes | One-time bulk batch, no automation needed |
Method 1: Google Apps Script Custom Function
This is the recommended approach for most teams. Google Apps Script is a JavaScript environment built into Google Workspace — every Google Sheets spreadsheet has access to it via Extensions → Apps Script. You do not need to install anything. The script runs inside Google's infrastructure, has access to the Cuttly API via UrlFetchApp, and can be called directly from a cell as a custom formula or triggered by a button or menu item.
Step 1: Open the Apps Script Editor
In your Google Sheet, go to Extensions → Apps Script. A new browser tab opens with the Apps Script editor. The default file is Code.gs. Delete any existing content and paste the script below.
Step 2: The Example Script
// ============================================================
// Cuttly URL Shortener for Google Sheets
// Replace YOUR_API_KEY with your Cuttly API key
//
// BRANDED DOMAIN NOTE (Regular API):
// The Regular API userDomain parameter accepts value "1" only.
// It uses whichever domain is set as ACTIVE in your Cuttly account.
// Before running, set your branded domain as active:
// Cuttly dashboard → Edit Account → Custom Domains → set active.
// ============================================================
var CUTTLY_API_KEY = 'YOUR_API_KEY'; // Store here or in PropertiesService
/**
* Custom formula: =SHORTENURL(A2)
* Shortens a single URL. Returns the short link or an error message.
*
* @param {string} url - The destination URL to shorten
* @param {string} [alias] - Optional custom alias
* @param {string} [domain] - Optional branded domain (e.g. go.yourbrand.com)
* @param {string} [tag] - Optional tag
* @return {string} Short link URL or error message
* @customfunction
*/
function SHORTENURL(url, alias, domain, tag) {
if (!url || url.toString().trim() === '') return '';
var params = {
key: CUTTLY_API_KEY,
short: url.toString().trim()
};
if (alias && alias.toString().trim() !== '') {
params.name = alias.toString().trim();
}
if (domain && domain.toString().trim() !== '') {
// Regular API: userDomain must be '1' — Cuttly uses the domain
// that is currently set as *active* in your account (Edit Account → Custom Domains).
// The domain name in column D is used here only as a reminder/label;
// ensure the correct domain is set as active in your Cuttly dashboard.
params.userDomain = '1';
}
if (tag && tag.toString().trim() !== '') {
params.tag = tag.toString().trim();
}
var queryString = Object.keys(params)
.map(function(k) {
return encodeURIComponent(k) + '=' + encodeURIComponent(params[k]);
})
.join('&');
var apiUrl = 'https://cutt.ly/api/api.php?' + queryString;
try {
var response = UrlFetchApp.fetch(apiUrl, { muteHttpExceptions: true });
var data = JSON.parse(response.getContentText());
if (data && data.url && data.url.status === 7) {
return data.url.shortLink;
} else {
var status = data && data.url ? data.url.status : 'unknown';
return 'ERROR: status ' + status;
}
} catch (e) {
return 'ERROR: ' + e.message;
}
}
/**
* Bulk function: run from the custom menu.
* Reads URLs from column A, writes short links to column B.
* Skips rows where column B is already populated.
* Optional: reads alias from column C, domain from column D, tag from column E.
*/
function shortenColumnA() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lastRow = sheet.getLastRow();
// Start from row 2 to skip header row
for (var row = 2; row <= lastRow; row++) {
var urlCell = sheet.getRange(row, 1); // Column A
var shortCell = sheet.getRange(row, 2); // Column B
var aliasCell = sheet.getRange(row, 3); // Column C (optional alias)
var domainCell= sheet.getRange(row, 4); // Column D (optional domain)
var tagCell = sheet.getRange(row, 5); // Column E (optional tag)
var url = urlCell.getValue().toString().trim();
// Skip empty URLs and rows already processed
if (!url || shortCell.getValue().toString().trim() !== '') continue;
var alias = aliasCell.getValue().toString().trim();
var domain = domainCell.getValue().toString().trim();
var tag = tagCell.getValue().toString().trim();
var shortLink = SHORTENURL(url, alias, domain, tag);
shortCell.setValue(shortLink);
// Rate limit: 1 request per second on Single plan (60/min)
Utilities.sleep(1100);
}
SpreadsheetApp.getUi().alert('Done! Check column B for short links.');
}
/**
* Add a custom menu to the spreadsheet on open.
*/
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Cuttly')
.addItem('Shorten column A → column B', 'shortenColumnA')
.addToUi();
}
Step 3: Add Your API Key Securely
For personal use, replace 'YOUR_API_KEY' at the top with your actual Cuttly API key (found in Edit Account → API in the Cuttly dashboard). For shared team spreadsheets where the code is visible to collaborators, use Apps Script's PropertiesService instead to avoid exposing the key in the script code:
// Store securely (run this once from the Apps Script editor Run menu):
function storeApiKey() {
PropertiesService.getScriptProperties().setProperty('CUTTLY_API_KEY', 'your_actual_key_here');
}
// Then retrieve in SHORTENURL:
var CUTTLY_API_KEY = PropertiesService.getScriptProperties().getProperty('CUTTLY_API_KEY');
Run storeApiKey() once from the Apps Script editor. After that, the key is stored in the script's properties rather than in the visible code. Delete the storeApiKey function after running it.
Step 4: Save and Grant Permissions
Save the script (Ctrl+S or Cmd+S). Go back to the Google Sheet and reload the page. A new "Cuttly" menu item should appear in the menu bar. Click Cuttly → Shorten column A → column B. Google will ask you to authorize the script to access external services (needed for UrlFetchApp to call the Cuttly API). Grant authorization. The script runs.
Using the Formula Version
After saving the script, you can also use SHORTENURL directly as a cell formula. In cell B2, type:
=SHORTENURL(A2)
Or with optional parameters:
=SHORTENURL(A2, C2, D2, E2)
Where A2 = destination URL, C2 = alias, D2 = branded domain, E2 = tag. If C2, D2, or E2 are empty, those parameters are omitted from the API call.
Important: custom formula calls to UrlFetchApp count against Google's daily quota for external URL fetches. For large sheets (hundreds of rows), use the bulk menu function (shortenColumnA()) rather than dragging the formula down the entire column — the bulk function runs once per row in sequence, while dragging a formula can trigger many simultaneous external requests that hit Google's fetch quota.
Adding Branded Domains and Custom Aliases from Sheet Columns
The script above already supports branded domains and custom aliases from sheet columns. Set up the spreadsheet with these columns:
| Column A | Column B | Column C | Column D | Column E |
|---|---|---|---|---|
| Destination URL | Short Link (output) | Alias (optional) | Domain (optional) | Tag (optional) |
| https://yourdomain.com/product-123 | [auto-filled] | product-123 | go.yourbrand.com | q3-launch |
| https://yourdomain.com/product-456 | [auto-filled] | product-456 | go.yourbrand.com | q3-launch |
Running Cuttly → Shorten column A → column B processes every row from row 2 downward, creating go.yourbrand.com/product-123 and go.yourbrand.com/product-456 as short links in column B. Rows where column B is already populated are skipped, making the function safe to re-run after adding new rows.
Important — how branded domains work with the Regular API: The Regular API userDomain parameter accepts the value 1 only (not a domain name string). When column D contains a domain name, the script uses it as a reminder that branded domain mode is requested — but Cuttly always uses whichever domain is set as active in your account. Before running the script, go to Edit Account → Custom Domains in your Cuttly dashboard and set the desired domain as active.
If you want branded domain links for all rows (no column D needed), the script already handles this correctly when any domain value is present. To hardcode it:
// In shortenColumnA(), this line triggers userDomain=1 for every row:
var domain = 'go.yourbrand.com'; // any non-empty value activates userDomain=1
// Make sure go.yourbrand.com is set as active in Edit Account → Custom Domains
Adding UTM Parameters from Sheet Columns
UTM parameters are appended to the destination URL before it reaches the Cuttly API. Add UTM-related columns to the sheet and construct the full UTM-tagged URL in a helper column (or directly in the script) before shortening.
Spreadsheet approach — a helper column F constructs the full UTM URL using a CONCATENATE formula, and the script reads column F instead of column A:
=CONCATENATE(A2,"?utm_source=",G2,"&utm_medium=",H2,"&utm_campaign=",I2)
In the script, change sheet.getRange(row, 1) to sheet.getRange(row, 6) (column F) for the URL source. The resulting short link points to the UTM-tagged destination, passing attribution to GA4 or your analytics platform.
Script approach — construct the UTM URL inside the script before the API call:
// Inside the loop in shortenColumnA():
var utmSource = sheet.getRange(row, 6).getValue(); // Column F
var utmMedium = sheet.getRange(row, 7).getValue(); // Column G
var utmCampaign = sheet.getRange(row, 8).getValue(); // Column H
if (utmSource) {
url += (url.indexOf('?') > -1 ? '&' : '?')
+ 'utm_source=' + encodeURIComponent(utmSource)
+ '&utm_medium=' + encodeURIComponent(utmMedium)
+ '&utm_campaign=' + encodeURIComponent(utmCampaign);
}
Method 2: IMPORTDATA Formula — Quick but Limited
Google Sheets' IMPORTDATA function can fetch the content of a URL. Since the Cuttly API returns plain text or JSON at a URL, IMPORTDATA can theoretically call it. The formula in cell B2 would be:
=IMPORTDATA("https://cutt.ly/api/api.php?key=YOUR_KEY&short="&ENCODEURL(A2))
Security warning: If this formula is placed in a shared spreadsheet, your API key is visible to anyone with access to the sheet or its formula bar. For any shared or team spreadsheet, use the Apps Script approach with PropertiesService instead.
Why this is not recommended for regular use: IMPORTDATA is designed for importing data feeds, not for calling APIs. Google caches and throttles external URL fetches in formulas heavily. The formula may work occasionally in testing but is unreliable for production use — Google can block, throttle, or return cached responses at any time. It also does not support custom aliases, branded domains, or tags. And since IMPORTDATA returns the full JSON response as text, you would need additional parsing to extract just the short link from the JSON string.
Use this approach only for occasional one-off shortening where you want to avoid any script setup. For regular use, the Apps Script method is significantly more reliable.
Method 3: Zapier or Make — No-Code Triggered Automation
If you prefer a no-code approach and want the shortening to happen automatically every time a new row is added — without opening a menu or running a script — Zapier or Make are the appropriate tools.
The workflow: Google Sheets — New Spreadsheet Row trigger fires when a row is added → Webhooks by Zapier (or Make HTTP module) calls the Cuttly API with the URL from the new row → Google Sheets — Update Spreadsheet Row writes the short link back to column B of the same row.
This approach requires a Zapier or Make account (both have free tiers that cover basic automation). The detailed configuration is covered in the Zapier and Make automation guide. The key difference from the Apps Script approach: Zapier/Make runs automatically on every new row without any user action, while the Apps Script menu function requires a human to click the menu item. For always-on, fully automatic workflows, Zapier/Make is the better choice. For on-demand bulk processing of an existing sheet, Apps Script is more practical.
Method 4: Manual Workflow — Cuttly CSV Export and Import
For one-time bulk shortening of an existing column of URLs — a scenario where you have a product catalogue that needs short links created once, not on an ongoing basis — the manual CSV workflow is the simplest approach with no technical setup.
Step 1: Export the URL column from Google Sheets as a CSV (File → Download → Comma Separated Values). Open the CSV in a text editor and confirm the format: one URL per row, no header.
Step 2: Import the CSV into Cuttly using the Link Importer (available from the Single plan — 100 links/month). The importer creates short links for every URL in the file. Optionally, add a second column to the CSV with custom aliases before import.
Step 3: Export the created links from the Cuttly dashboard (also available from the Single plan). The export CSV includes the short link URL, destination URL, alias, and creation date for each link.
Step 4: Use VLOOKUP in Google Sheets to match the exported short links back to the original spreadsheet by destination URL, populating the short link column automatically.
This four-step workflow takes 10–15 minutes for batches up to 100 URLs (Single plan limit) and requires no technical knowledge or scripting. For larger batches (up to 2,000 on Team plan), the same approach scales.
Setting Up a Sheet Template for Campaign Link Management
For marketing teams that regularly create campaign links in Google Sheets, a standardised template makes the workflow consistent and the analytics comparable across campaigns. A recommended column structure:
| Col | Header | Example value | Notes |
|---|---|---|---|
| A | Campaign | Summer Launch 2026 | For reference only |
| B | Channel | For reference; also used as utm_medium | |
| C | Destination URL | https://yourdomain.com/offer | Raw destination |
| D | Alias | summer-email | Custom alias for short link |
| E | UTM Source | newsletter | utm_source value |
| F | UTM Medium | utm_medium value | |
| G | UTM Campaign | summer-launch-2026 | utm_campaign value |
| H | Full UTM URL (formula) | =C2&"?utm_source="&E2&"&utm_medium="&F2&"&utm_campaign="&G2 | Constructed destination |
| I | Short Link | [auto-filled by script] | Output column |
| J | Notes | Email header CTA | Free text |
The script reads column H (the full UTM URL formula) as the destination and column D as the alias, writing the short link to column I. This template ensures every short link automatically includes UTM attribution and a meaningful alias, without any manual URL construction.
A completed campaign row in this template takes 30 seconds to fill in — campaign name, channel, destination URL, alias, and UTM values. Running the script fills in the short link column. The sheet becomes the single source of truth for all campaign links, with the short link readily available for copying into email designs, social posts, and print materials.
Which Cuttly Plan to Use
The Free plan ($0) is suitable for testing the Apps Script integration and creating a small number of short links (up to 30/month on the cutt.ly domain, 3 API calls/60s). Adequate to validate the script works before upgrading.
The Single plan ($25/month) is appropriate for most teams using Google Sheets for campaign link management: 5,000 links/month, 60 API calls/60s (sufficient for batch processing), 1,000 branded domain links/month via API, CSV import (100 links/month) for the manual workflow approach, and CSV export from the dashboard.
The Team plan ($99/month) is needed for: high-volume Google Sheets workflows creating thousands of links per month, organizations that need a workspace-level API key (Team API) rather than a personal key in the script, and teams requiring 2,000+ CSV imports per month or 20,000+ branded domain links via API.
Get started with Cuttly's free plan — no credit card required. Copy your API key from Edit Account → API, paste it into the Apps Script code above, and you will have your first automated short link created from Google Sheets in under 10 minutes.
Frequently Asked Questions
Can I shorten URLs automatically in Google Sheets?
Yes — three automation approaches: (1) Google Apps Script custom function calling the Cuttly API — most reliable and fully featured; (2) Zapier or Make automation watching for new rows and creating short links automatically; (3) Cuttly CSV import + export for one-time bulk processing. The Apps Script approach is recommended for most teams.
Is there a Google Sheets formula to shorten a URL?
No built-in formula — but the Apps Script custom function in this guide creates a =SHORTENURL(A2) formula that works like a native formula. IMPORTDATA with the API endpoint is technically possible but unreliable for production use. The Apps Script approach is the correct solution.
How do I use the Cuttly API in Google Apps Script?
Extensions → Apps Script → paste the script from this guide. Replace YOUR_API_KEY with your Cuttly API key (from Edit Account → API). Save and reload the sheet. A "Cuttly" menu item appears. Grant authorization when prompted. The script uses UrlFetchApp.fetch() to call the Cuttly API and JSON.parse() to extract the short link from the response.
Can I create branded short links from Google Sheets?
Yes — add your branded domain (e.g. go.yourbrand.com) to column D of the sheet template. The script sets userDomain=1 when a domain name is present in column D (the Regular API uses whichever domain is active in your account, not a domain name string). The domain must be verified and set as active in Edit Account → Custom Domains in your Cuttly dashboard. Branded domain API links: 1,000/month on Single plan, 20,000/month on Team.
- Tools
- URL Shortener Tool →
- Link Analytics →
- API Documentation
- Cuttly API Reference →
- Related Guides
- URL Shortener with Zapier & Make →
- URL Shortener API Developer Guide →
- Bulk URL Shortening Guide →
- UTM Strategy Guide →
- UTM Parameters Setup →
- Link Tracking 101 →
- Start Here
- Create Free Account
- Plans & Pricing
URL Shortener
Cuttly simplifies link management by offering a user-friendly URL shortener that includes branded short links. Boost your brand’s growth with short, memorable, and engaging links, while seamlessly managing and tracking your links using Cuttly's versatile platform. Generate branded short links, create customizable QR codes, build link-in-bio pages, and run interactive surveys—all in one place.
Cuttly - Consistently Rated
Among Top URL Shorteners
Cuttly isn’t just another URL shortener. Our platform is trusted and recognized by top industry players like G2 and SaaSworthy. We're proud to be consistently rated as a High Performer in URL Shortening and Link Management, ensuring that our users get reliable, innovative, and high-performing tools.