Google is committed to advancing racial equity for Black communities. See how.

URL Shortener Service

The URL Shortener service allows you to use the URL Shortener API in Apps Script. This API gives users the ability to manage and report on their short links.


For detailed information on this service, see the reference documentation for the URL Shortener API. Like all advanced services in Apps Script, the URL Shortener service uses the same objects, methods, and parameters as the public API.

Sample code

The sample code below uses version 1 of the API.

Get clicks

This sample gets the number of clicks the short URL received in the last week.

 * Logs the number of clicks to a short URL over the last week.
 * @param  {string} shortUrl The short URL.
function getClicks(shortUrl) {
  var url = UrlShortener.Url.get(shortUrl, {
    projection: 'ANALYTICS_CLICKS'
  Logger.log('The URL received %s clicks this week.',;