Digital marketers along with content creators and social media managers face the daily difficulty of handling dozens or hundreds of links. Unwieldy long URLs appear unprofessional and waste precious character real estate in social media posts while risking display errors in email messages. When shortening URLs by hand works for small tasks but turns into a time-draining process with numerous links needed for campaigns or reports. 


The necessity for bulk URL shortening emerges in situations where multiple links need management. Automatic conversion of long URLs into short trackable links enables you to: 

  • Save hours of tedious manual work 
  • Maintain consistent branding across all links 
  • Scaling up tracking click metrics produces superior analytics outcomes. 
  • Improve the visual appeal of your communications 
  • You can minimize the possibility of dead links appearing in your emails and documents. 



Bitly has established itself as one of the most trusted URL shortening services, used by 55% of Fortune 500 companies. Beyond basic shortening, Bitly offers robust tracking features, allowing you to monitor clicks, geographic data, and referral sources—critical metrics for optimizing your digital marketing strategy. 

When combined with Google Sheets and a bit of script magic, Bitly transforms into a powerful bulk processing tool that can handle hundreds of URLs in minutes, a process we'll walk through in detail below. 




First, create a new Google Sheet where you'll manage your URLs: 


  • Open Google Sheets and create a new spreadsheet 
  • Label Column A as "Original URLs" and Column B as "Shortened URLs" 
  • Enter all the URLs you need to shorten in Column A, ensuring each URL starts with either "http://" or "https://" 

For organization, consider adding additional columns for tracking purposes, such as "Destination Page," "Campaign Name," or "Placement" to help categorize your links for future reference. 



Next, we'll add the script that will communicate with Bitly's API: 


  1. Click on "Extensions" in the top menu of your Google Sheet 
  1. Select "Apps Script" from the dropdown menu 
  1. This will open a new tab with the Google Apps Script editor 
  1. Give your project a descriptive name like "Bitly URL Shortener" 

The Apps Script environment is where we'll add the code that sends each URL to Bitly and retrieves the shortened version. 


In the Apps Script editor, paste the following code: 

Complete Apps Script Code download link below




To authenticate with Bitly's API, you'll need an access token: 


  1. Log into your Bitly account dashboard 
  1. Click on the settings icon (gear) in the left sidebar 
  1. Navigate to "Developer Settings" 
  1. Select the "API" section 
  1. Enter your password when prompted for security verification 
  1. Click the "Generate Token" button 
  1. Copy the access token that appears 

This token is your key to Bitly's API services. In the script we added earlier, replace "YOUR_BITLY_ACCESS_TOKEN_HERE" with the actual token you just copied. 



With the script in place and your API key configured: 


  1. Click the "Save" button (disk icon) in the Apps Script editor 
  1. Click the "Run" button (play icon) to execute the function 
  1. When prompted, click "Review Permissions" 
  1. Select your Google account 
  1. Grant the necessary permissions by clicking "Allow" 

During the first run, Google will verify the script's security. This is standard procedure for any custom script and requires your explicit authorization. 



The script will now process each URL in your sheet: 


  1. Check the execution log in Apps Script for any errors or messages 
  1. Return to your Google Sheet, where you should see shortened URLs appearing in Column B 
  1. Verify a few links by clicking on them to ensure they redirect properly 

For large batches of URLs, the process may take several minutes depending on the number of links and Bitly's API response time. 




To streamline future URL shortening tasks, add a button directly to your sheet: 


  1. In Google Sheets, click Insert > Drawing 
  1. Create a simple button shape and add text like "Shorten URLs" 
  1. Click "Save and Close" 
  1. Right-click on the button and select "Assign script" 
  1. Enter "shortenUrls" (the name of our function) and click OK 

Now you can shorten URLs with a single click anytime you update your list. 



For more advanced marketing analytics, consider modifying the script to add UTM parameters to your links before shortening: 


// Example modification to add UTM parameters 
var longUrlWithUtm = longUrl + "?utm_source=newsletter&utm_medium=email&utm_campaign=spring2025"; 
var shortUrl = createBitlyShortUrl(longUrlWithUtm, accessToken); 
 


This enhancement is particularly useful for our email marketing campaign tracking workflows and helps segment traffic sources more effectively. 




This automated shortening process is beneficial in various scenarios:


  • Marketing Campaigns: Quickly generate short links for your campaigns and track their performance via Bitly's analytics.

  • Social Media Posts: Prepare posts with shortened links ahead of time, making it easier to share them across your social media platforms.

  • Email Newsletters: Incorporate clean, short URLs into your email marketing, improving click-through rates and overall engagement.

  • Content Management: For bloggers or content creators, this script helps manage and share various links without cluttering your communications.


Automating URL shortening with Google Apps Script and the Bitly API can save you time while enhancing your content's shareability and performance. If you frequently work with URLs, integrating this script into your workflow can streamline the process and provide you with valuable insights on your link performance.


By using this approach, you not only improve the aesthetics of your links but also gain access to Bitly's powerful analytics, allowing you to optimize your marketing strategies effectively.