Google Sheets Setup
Connect your Google Sheet to receive WordPress form submissions with SheetLinkWP. Step-by-step setup guide.
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
- Create a new Google Sheet (or open an existing one)
- Go to Extensions > Apps Script
- Delete any existing code in
Code.gs - 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.
- In the Apps Script editor, click Deploy > New deployment
- Click the gear icon next to "Select type" and choose Web app
- Set Description to anything (e.g., "SheetLinkWP Receiver")
- Set "Execute as" to Me
- Set "Who has access" to Anyone
- Click Deploy
- Authorize the script when prompted (click through the "unsafe" warning - this is your own script running under your account)
- Copy the Web app URL - it looks like
https://script.google.com/macros/s/.../exec - Paste this URL into SheetLinkWP's "Receiver URL" field
/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.
- Go to Deploy > Manage deployments
- Click the Edit (pencil) icon
- Change Version to "New version"
- 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
doPost (case-sensitive). Check that you pasted the code into Code.gs, not a different file./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.