Google Sheets Integration

Setup Instructions

Connect your website forms to Google Sheets automatically. All form submissions will be organized into separate tabs for easy lead management.

What This Setup Does

Newsletter Signups

Email subscriptions go to "Newsletter" tab

Contact Forms

Contact inquiries go to "Contact" tab

Planning Questionnaire

Detailed questionnaire responses go to "Planning" tab

1

Create Google Spreadsheet

Create a new Google Spreadsheet with three separate tabs:

Newsletter Tab

Columns: Date, Email, Source

Contact Tab

Columns: Date, Name, Email, Phone, Company, Message, Source

Planning Tab

Columns: Date, Name, Email, Phone, Message, Vision, Maintenance, Project Type, Location, Space, Viewing, Experience, Source

2

Create Google Apps Script

In your Google Spreadsheet:

  1. Click Extensions → Apps Script
  2. Delete the default code and paste the provided script
  3. Click Deploy → New Deployment
  4. Choose "Web app" as type
  5. Set execution as "Me" and access to "Anyone"
  6. Click Deploy and copy the Web App URL
3

Update Website Configuration

Replace the placeholder URL in your website's JavaScript files:

Find this line in each JavaScript file:

const GOOGLE_APPS_SCRIPT_URL = 'YOUR_GOOGLE_APPS_SCRIPT_URL_HERE';

Replace with your actual URL:

const GOOGLE_APPS_SCRIPT_URL = 'https://script.google.com/macros/s/YOUR_SCRIPT_ID/exec';

Files to Update:

  • Planning Questionnaire page JavaScript
  • Contact Us page JavaScript
  • Blog page JavaScript (for newsletter)

Google Apps Script Code

Copy and paste this code into your Google Apps Script editor:

function doPost(e) {
  try {
    const data = JSON.parse(e.postData.contents);
    const sheet = SpreadsheetApp.getActiveSpreadsheet();
    
    // Get form type from data
    const formType = data.serviceType || data.formType || 'contact';
    
    let targetSheet;
    let row = [new Date()]; // Always start with timestamp
    
    if (formType === 'newsletter') {
      targetSheet = sheet.getSheetByName('Newsletter');
      row.push(data.email, data.source || 'Website');
    } 
    else if (formType === 'planning-questionnaire') {
      targetSheet = sheet.getSheetByName('Planning');
      // Parse questionnaire data if it's JSON string
      let questionnaireData = {};
      try {
        questionnaireData = JSON.parse(data.questionnaireData || '{}');
      } catch (e) {
        questionnaireData = {};
      }
      
      row.push(
        data['first-name'] || data.name,
        data.email,
        data.phone,
        data.message || '',
        questionnaireData.vision || '',
        questionnaireData.maintenance || '',
        questionnaireData.projectType || '',
        questionnaireData.location || '',
        questionnaireData.space || '',
        questionnaireData.viewing || '',
        questionnaireData.experience || '',
        data.source || 'Website'
      );
    }
    else {
      // Default contact form
      targetSheet = sheet.getSheetByName('Contact');
      row.push(
        data.name,
        data.email,
        data.phone || '',
        data.company || '',
        data.message || '',
        data.source || 'Website'
      );
    }
    
    if (targetSheet) {
      targetSheet.appendRow(row);
    }
    
    return ContentService
      .createTextOutput(JSON.stringify({success: true}))
      .setMimeType(ContentService.MimeType.JSON);
      
  } catch (error) {
    return ContentService
      .createTextOutput(JSON.stringify({success: false, error: error.toString()}))
      .setMimeType(ContentService.MimeType.JSON);
  }
}

You're All Set!

Once you complete these steps, all form submissions will automatically be sent to your Google Spreadsheet with organized tabs for easy lead management.