Section 1: Creating a Google Site

We need to create a Google Site. If you do not already have a Google Site, use the instructions in this section to create a Site. If you already have a Site where you want to develop this Apps Script, skip the instructions below and go to Section 2.

To create a Google Site:

  1. Open this URL to go to Google Sites. You will see the Google Sites that you own. If do not own any Sites, you need to create a new Google Site.
  2. Click Create Site.
  3. In the Name your Site field, type Apps Script in Sites. The field Your site will be located at this URL auto-completes. A Captcha code is displayed for confirmation purposes.
  4. Type in the confirmation code.
  5. Click Create Site.

Section 2: Creating an Apps Script in a Google Site

To insert a script into the new Sites page, you need to start the Script Editor.

To start the Script Editor and insert the script:

  1. Click More Actions > Manage Site.
  2. In the left-hand sidebar, click Apps Scripts.
  3. Click Launch Editor.

  4. Copy and paste the following code into the editor, ensuring that you paste over the default function that is in the editor.
    function doGet(e) {
    var app = UiApp.createApplication();
    // hello world label
    var helloworldLabel = app.createLabel("I love Apps Script!").setStyleAttribute("fontSize","16px");
    // add the label to the app container
    return app;
  5. Click the Save icon.
  6. Give the script a name and click Save.
  7. Close the Script Editor window.
  8. Click the Return to Site link. You have now created a script in Google Sites.

Section 3: Creating a Sites Page to Host the Hellow World Script

Now we need to create the Google Sites Page that will host the script and display the user interface for the hello world application. This is very easy.

To create a Sites page:

  1. On the top right hand corner of the Site, click Create Page.
  2. Choose the default Web Page template.
  3. In the Name field, type Hello World.
  4. To change the location of the page, select Put page under Home or click Choose a different location and select the new location on the dialog box.
  5. Click Create Page.

Section 4: Embedding a Google Apps Script Gadget in the Sites Page

The Hello World script is installed and we need to embed it in the Sites page. The Sites page will display the user interface for the application. All scripts are embedded into a Sites page as Google Apps Script Gadgets.

To embed a Gadget in a Sites page:

  1. Click Edit Page
  2. Click Insert > Apps Script Gadget.

  3. Select the script you just created. Upon selection, you will see a warning page which tells you that any user who is accessing the Sites page will the script as YOU. This is a very important security consideration when you are developing scripts.
  4. Click Save.

You now have an Apps Script Gadget embedded in your Sites page.

Section 5: Running the Hello World Application

Our hello world application is ready now. Look on the left-hand side of your sites page for the URL of the application. To run the application, click the URL of the page where you inserted the Apps Script gadget. You'll see the following: