Skip to main content
Apps Script can receive each survey response from the Widget Studio and append it as a row in a Google Sheet.
If you want to collect responses from your widget in Kameleoon and export them to CSV, refer to the Survey data export article.

Configure your Google Sheet

  1. Go to Google Sheets and create a new spreadsheet.
  2. Name the tab Sheet1 (which is the default).
  3. In the first row, define the columns as follows:
    Google Sheet with Date in cell A1 and placeholder survey element names in cells B1 and C1
    Details:
    • Column A: Enter Date. The script fills this cell with the date and time of each submission.
    • From column B onward: Enter the name of each survey or form element added to your widget.
    You can find an element’s name in the elements tree in the Content tab of the Design section.
    Widget Studio Content tab with the NPS Screen and an Elements list showing Popup, Close, Heading, Scale, Long Answer, Submit button, and Background
    When you select an element (for example, a scale), its name appears at the top of the editing sidebar.
    Scale element settings with Scale type set to Emoji, an Edit name tooltip, and an emoji feedback widget on the canvas
    Consider this widget as an example:
    Widget Studio Content tab and a We value your feedback survey preview with emoji scale, comment field, and Submit button
    This widget has two survey elements, so enter the following in the first row of the Google Sheet:
    • Column A: Date
    • Column B: Scale
    • Column C: Long Answer
Add the Google Apps Script to your spreadsheet:
  1. Click Extensions > Apps Script. A new Google Script opens. Rename it. For example, use “form data.”
    Blank Google Sheets spreadsheet named Untitled spreadsheet, with the pointer on the Extensions menu
  2. Replace all code with the following:
    If you can’t name your tab “Sheet1,” change the value of sheetName in the first line of the script to your tab’s actual name.
    Google Apps Script editor for a project named My form data, showing Code.gs with the initialSetup and doPost functions
  3. Click Save project to Drive (to the left of Run).
  4. In the dropdown to the right of Debug, select initialSetup (usually selected by default).
  5. Click Run. You might see a pop-in asking for permissions. Click Review permission and continue to the next screen. Because Google hasn’t reviewed the script, a warning message may appear. Click Go to form data (unsafe) to grant the permissions that let the script update your spreadsheet.
    Google warning page Google hasn't verified this app, with an arrow pointing to the Go to Mailing List (unsafe) link
    After you grant the permissions, the console shows Execution completed.
    Apps Script Execution log showing Execution started and Execution completed notices
  6. In the left menu, click Triggers to add a trigger for the script.
    Apps Script Triggers page with a trigger for the doPost function from spreadsheet on form submit
  7. Click Add trigger. In the window that appears, select the following options:
    • Choose which function to run: doPost
    • Choose which deployment should run: Head
    • Select event source: From spreadsheet
    • Select event type: On form submit
    Google Apps Script 'Edit Trigger for My form data' dialog with doPost, Head, From spreadsheet, On form submit, and Save
  8. Click Save.
  9. Click Deploy > New deployment.
  10. Click the cog icon next to Select type > Web app. In the form that appears, select the following options:
    • Description: Use a descriptive name, such as “form data.”
    • Web app > Execute as: Me
    • Web app > Who has access: Anyone
  11. Click Deploy.
    Who has access: Anyone is required for the widget to send responses to your spreadsheet.
    New deployment dialog showing the deployment ID and Web app URL, with the Copy button under the URL highlighted
  12. Copy the URL.

Configure survey settings in the Widget Studio

  1. In the Survey Settings tab, turn on Collect survey data.
  2. Under When is the survey submitted?, select A button is clicked, then choose the button that visitors click to submit.
  3. Under How are responses collected?, choose Externally (HTTP Request).
    • Request name: Name your request. For example, use “send data to Google Sheet.”
    • Method: Select POST.
    • Action URL: Paste the URL generated by your Google Apps Script.
  4. Save your configuration.

Test your setup

  1. Preview your widget.
  2. Fill out the survey and Submit.
  3. Go back to your Google Sheet.
You should now see a new row with your response.