Google Sheets Setup

Connect your Google Sheet to receive WordPress form submissions with SheetLinkWP. Step-by-step setup guide.

Available on: Free Freelancer Agency Enterprise

Overview

SheetLinkWP sends form data to a Google Apps Script web app deployed on your Google Sheet. There are two setup methods:

  • Copy our pre-built template (recommended) - takes about 1 minute
  • Paste the script manually - useful if you have an existing sheet

Both methods use the same Apps Script. Pick whichever works best for your situation, then deploy it as a web app to get the receiver URL.

Method 1: Copy Template (Recommended)

Click the button below to create a copy of our template sheet. The Apps Script is already included - no code to paste.

This creates a copy of our template sheet with the Apps Script already included.

After copying, go to Extensions > Apps Script to verify the code is there. Then proceed to Deploy as Web App below.

Method 2: Manual Setup

  1. Create a new Google Sheet (or open an existing one)
  2. Go to Extensions > Apps Script
  3. Delete any existing code in Code.gs
  4. Paste the following script:
function doPost(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var data = JSON.parse(e.postData.contents);

  // Create header row on first submission
  if (sheet.getLastRow() === 0) {
    sheet.appendRow(Object.keys(data));
  }

  // Get current headers
  var lastCol = sheet.getLastColumn();
  var headers = lastCol > 0
    ? sheet.getRange(1, 1, 1, lastCol).getValues()[0]
    : [];

  // Auto-add columns for any new fields
  var keys = Object.keys(data);
  for (var i = 0; i < keys.length; i++) {
    if (headers.indexOf(keys[i]) === -1) {
      headers.push(keys[i]);
      sheet.getRange(1, headers.length).setValue(keys[i]);
    }
  }

  // Build row in header order
  var row = headers.map(function(h) { return data[h] || ''; });
  sheet.appendRow(row);

  return ContentService.createTextOutput(
    JSON.stringify({ status: 'ok' })
  ).setMimeType(ContentService.MimeType.JSON);
}

// Run this to verify the script works
function testDoPost() {
  doPost({ postData: { contents: JSON.stringify({
    timestamp: new Date().toLocaleString(),
    name: 'Test User',
    email: 'test@example.com',
    message: 'Hello from SheetLinkWP!'
  })}});
  Logger.log('Test row added!');
}

Save the script (Ctrl+S / Cmd+S), then proceed to deploy it below.

Deploy as Web App

Whether you used the template or pasted the script manually, you need to deploy it as a web app to get a URL that SheetLinkWP can send data to.

  1. In the Apps Script editor, click Deploy > New deployment
  2. Click the gear icon next to "Select type" and choose Web app
  3. Set Description to anything (e.g., "SheetLinkWP Receiver")
  4. Set "Execute as" to Me
  5. Set "Who has access" to Anyone
  6. Click Deploy
  7. Authorize the script when prompted (click through the "unsafe" warning - this is your own script running under your account)
  8. Copy the Web app URL - it looks like https://script.google.com/macros/s/.../exec
  9. Paste this URL into SheetLinkWP's "Receiver URL" field
Important: The URL must end in /exec (not /dev). The /dev URL is for testing only and won't accept external POST requests.

Re-deploying After Changes

If you edit the Apps Script code, you must create a new deployment version for changes to take effect.

  1. Go to Deploy > Manage deployments
  2. Click the Edit (pencil) icon
  3. Change Version to "New version"
  4. Click Deploy

The URL stays the same - no need to update it in SheetLinkWP.

Multiple Tabs

By default, data goes to the active (first) sheet tab. To route submissions to specific tabs based on rules, use SheetLinkWP's Conditional Routing feature.

When routing rules match, the tab name is sent as part of the payload so the script knows where to write the data.

See Conditional Routing for setup details.

Troubleshooting

"Authorization required"
Re-authorize the script. Go to the Apps Script editor, click Run > doPost, or create a new deployment to trigger the auth prompt again.
"Script function not found"
Make sure the function is named exactly doPost (case-sensitive). Check that you pasted the code into Code.gs, not a different file.
"The script completed but did not return anything"
Check that you're using the /exec URL, not the /dev URL. The /dev endpoint doesn't accept external requests.

For more help, see the full Troubleshooting Guide.

Ready to Get Started?

Install SheetLink Forms and connect your first form in under 10 minutes.