Web Apps and Google Sites Gadgets

If you build a user interface for a script, you can publish the script as a web app. For example, a script that lets users schedule appointments with members of a support team would best be presented as a web app so that users can access it directly from their browsers.

Both standalone scripts and scripts bound to Google Apps can be turned into web apps, so long as they meet the requirements below.

Requirements for web apps

A script can be published as a web app if it meets these requirements:

Deploying a script as a web app

To publish a script as a web app, follow these steps:

  1. Save a new version of the script by selecting File > Manage Versions, then Save New Version.
  2. Select Publish > Deploy as web app.
  3. Under Project version, select the version you just saved.
  4. Under Execute the app as, select whose authorization the app should run with: your account (the developer's) or the account of the user who visits the app.
  5. Under Who has access to the app, select who should be allowed to visit it. The options differ depending on the type of account you have, but they can include "Only myself", any member of your domain, "Anyone" (with a Google account), or "Anyone, even anonymous".
  6. Click Deploy.

Once you click Deploy, you'll see a new dialog with a message indicating that your project has been successfully deployed as a web app.

This dialog provides two important URLs for your app:

  • The first is labeled Current web app URL and ends in /exec. This URL is for the published version of your app, based on the last version you saved and deployed.
  • The second is the link labeled latest code and ends in /dev. This URL can only be accessed by users who have edit access to the script. This instance of the app always runs the most recently saved code — not necessarily a formal version — and is intended for quick testing during development.

You can share the web app URL with those you would like to use your app, provided you have granted them access. It is also possible to distribute web apps in the Chrome Web Store for public use.

Embedding your web app in Google Sites

Web apps can also be embedded in Google Sites. (These embedded web apps are sometimes called Google Sites Gadgets.)

To create a script that is bound to Google Sites, visit your site, click the gear icon, then select Manage site. Click Google Apps Scripts, then Add new script. After that, the process is the same as for creating and deploying a web app as above.

To embed your web app in Google Sites, follow the steps below:

  • Open an existing Site for which you have edit access or create a new Site.
  • Navigate to the page in your Site where you want to embed the web app.
  • Click the edit icon, and then Insert > Google Apps Script.
  • Choose the script from the list that represents your web app. If your web app is not bound to this Site, you can paste in the web app URL instead.
  • Click the Select button, choose the desired options from the next dialog, and click Save.
  • Save your changes to the page and then you should see your web app embedded in your Sites page.

URL parameters

When a user visits an app or a program sends the app an HTTP GET request, Apps Script runs the function doGet(e). When a program sends the app an HTTP POST request, Apps Script runs doPost(e) instead. In both cases, the e argument represents an event parameter that can contain information about any URL parameters. The structure of the event object is shown in the table below:


The value of the query string portion of the URL, or null if no query string is specified


An object of key/value pairs that correspond to the request parameters. Only the first value will be returned for parameters that have multiple values.

{"name": "alice", "n": "1"}

An object similar to e.parameter, but with an array of values for each key

{"name": ["alice"], "n": ["1", "2"]}
e.contextPath Not used, always the empty string.

The length of the request body for POST requests, or -1 for GET requests


The same as e.contentLength


The MIME type of the POST body


The content text of the POST body


Always the value "postData"


For instance, you could pass parameters such as username and age to a URL as shown below:


Then, you can display the parameters like so:

function doGet(e) {
  var params = JSON.stringify(e);
  return HtmlService.createHtmlOutput(params);

In the above example, doGet(e) returns the following output:

  "queryString": "username=jsmith&age=21",
  "parameter": {
    "username": "jsmith",
    "age": "21"
  "contextPath": "",
  "parameters": {
    "username": [
    "age": [
  "contentLength": -1


The permissions for a web app differ depending on whether you choose to execute the app as the owner of the script or as the active user who is accessing the web app.

If you choose for the script to execute as you, then the script will always execute under your identity, that is, the identity of the owner of the script. This will be the case regardless of which user is accessing the web app.

If you choose for the script to execute as the user who accesses the web app, then the script will execute under the identity of the active user who is accessing your script.

Send feedback about...

Apps Script
Apps Script