You can shorten URLs to make them easier to share using the Google URL shortener. For example, the short URL http://goo.gl/l6MS takes people to http://googleblog.blogspot.com/2009/12/making-urls-shorter-for-google-toolbar.html.
Create a shortened URL
- Visit the Google URL shortener site at goo.gl.
- If you aren’t signed in, click the Sign in button in the top right corner.
- Write or paste your URL in the Paste your long URL here box.
- Click Shorten URL.
Below the “Paste your URL here” box, you’ll see the long version of your url and the short version. Once created, your link won’t expire unless it has to be removed for spam, privacy, or legal reasons.
Track the use of your URL
You can see how many people have clicked on your URL by visiting goo.gl.
For more detailed information about the URL’s use, including the countries, browsers, and platforms that accessed it, add .info to the end of your short URL. For example, detailed tracking for http://goo.gl/l6MS can be found at http://goo.gl/l6MS.info.
Tracking for all goo.gl short links are publicly visible to all users.
Get app deep links with the URL Shortener
The URL Shortener also offers the capability of having short links deep link to content in your mobile apps. In order for this to be enabled, you must integrate with App Indexing for Android and iOS. After integrating, any short link which redirects to a web link that you have provided to Google through App Indexing will open automatically in your native app for your users.
Once you’ve integrated with App Indexing and your deep links are enabled with goo.gl, you can integrate the URL Shortener API into your app or website’s share flow to allow your users to share links that provide the best possible experience on every platform.
Google URL Shortner API help
Below, we walk you through the steps to interact with the Google URL Shortener API. This is the programmatic side of the web site at goo.gl. To begin, you should read the section on Authentication. After that, you can skip ahead to the section describing whichever action you would like to perform.
Each section contains a brief description, an example, and a link to more detailed information. The examples in this guide all use a REST-style JSON protocol.
The examples use
curl and OACurl to show you how to get started interacting with the API quickly, right from the command line. When developing your application, however, feel free to use your preferred HTTP, JSON, and OAuth libraries.
Authorizing requests and identifying your application
Every request your application sends to the Google URL Shortener API needs to identify your application to Google. There are two ways to identify your application: using an OAuth 2.0 token (which also authorizes the request) and/or using the application’s API key. Here’s how to determine which of those options to use:
- If the request requires authorization (such as a request for an individual’s private data), then the application must provide an OAuth 2.0 token with the request. The application may also provide the API key, but it doesn’t have to.
- If the request doesn’t require authorization (such as a request for public data), then the application must provide either the API key or an OAuth 2.0 token, or both—whatever option is most convenient for you.
About authorization protocols
Authorizing requests with OAuth 2.0
Requests to the Google URL Shortener API for non-public user data must be authorized by an authenticated user.
The details of the authorization process, or “flow,” for OAuth 2.0 vary somewhat depending on what kind of application you’re writing. The following general process applies to all application types:
- When you create your application, you register it using the Google API Console. Google then provides information you’ll need later, such as a client ID and a client secret.
- Activate the Google URL Shortener API in the Google API Console. (If the API isn’t listed in the API Console, then skip this step.)
- When your application needs access to user data, it asks Google for a particular scope of access.
- Google displays a consent screen to the user, asking them to authorize your application to request some of their data.
- If the user approves, then Google gives your application a short-lived access token.
- Your application requests user data, attaching the access token to the request.
- If Google determines that your request and the token are valid, it returns the requested data.
Some flows include additional steps, such as using refresh tokens to acquire new access tokens. For detailed information about flows for various types of applications, see Google’s OAuth 2.0 documentation.
Here’s the OAuth 2.0 scope information for the Google URL Shortener API:
To request access using OAuth 2.0, your application needs the scope information, as well as information that Google supplies when you register your application (such as the client ID and the client secret).
Tip: The Google APIs client libraries can handle some of the authorization process for you. They are available for a variety of programming languages; check the page with libraries and samples for more details.