A Google Apps Script-optimized behavior logging form that tracks activities and their impact on personal well-being. Uses proven Google Apps Script patterns for reliable deployment and data storage in Google Sheets.
- 🎯 Reliable Design: Uses only proven Google Apps Script patterns that work reliably every time
- 📱 Single-File Architecture: Simple HTML form that deploys directly to Google Apps Script
- ⚡ Energy Impact Tracking: Visual slider with color-coded feedback (1-10 scale)
- 💎 Wealth Type Classification: Track impact on Physical, Mental, Social, Financial, and Time wealth
- 📊 Direct Google Sheets Integration: No external APIs - direct server-side sheet writing
- 🔒 Built-in Validation: Both client-side and server-side validation with proper error handling
- 📋 No Blank Page Issues: Uses Google Apps Script function calls for seamless submission
- ♿ Accessible Design: Works in all browsers and assistive technologies
- Google Account (for Apps Script and Sheets)
-
Open Google Apps Script:
- Go to script.google.com
- Click "New Project"
-
Replace the Server Code:
- Select all default code in
Code.gsand delete it - Copy entire contents of
code.gsfrom this repository - Paste into Google Apps Script editor
- Save (Ctrl/Cmd + S)
- Select all default code in
-
Add the HTML File:
- Click "+" next to "Files" → Select "HTML"
- Name it exactly "index" (no file extension)
- Delete any default content
- Copy entire contents of
index.htmlfrom this repository - Paste into the HTML editor
- Save (Ctrl/Cmd + S)
-
Deploy as Web App:
- Click "Deploy" → "New deployment"
- Click gear icon ⚙️ next to "Type" → Select "Web app"
- Execute as: "Me"
- Who has access: "Anyone" (or "Anyone with Google account")
- Click "Deploy"
- Authorize when prompted (grant all permissions)
- Copy the Web app URL
-
Test the Form:
- Visit the deployment URL
- Fill out and submit the form
- Check your Google Drive for the automatically created "Behavior Log Data" spreadsheet
behavior-log/
├── code.gs # Server-side Google Apps Script code (DEPLOY THIS)
├── index.html # Complete HTML form (deploy as "index")
├── README.md # This file - includes deployment instructions
└── CLAUDE.md # Developer guidance
Making changes to the form is simple:
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/behavior-log.git cd behavior-log -
Edit files directly:
- Modify
code.gsfor server-side changes - Modify
index.htmlfor form and styling changes - No build process required
- Modify
-
Test changes:
- Copy updated files to Google Apps Script
- Deploy and test functionality
- All files are ready-to-deploy
For a more professional development experience, you can use Google Clasp:
# Install Clasp globally
npm install -g @google/clasp
# Login to your Google account
clasp login
# Create new Apps Script project
clasp create --type webapp --title "Behavior Logger"
# Copy project files to Clasp structure
cp code.gs src/Code.gs
cp index.html src/index.html
# Push to Google Apps Script
clasp push
# Deploy as web app
clasp deployClasp Benefits:
- ✅ Command-line deployment (
clasp push) - ✅ Local development with full IDE support
- ✅ TypeScript support available
- ✅ Better version control integration
- ✅ Automated deployment workflows
Trade-offs:
- ➕ Professional development workflow
- ➖ Requires Node.js installation
- ➖ Additional setup complexity
Choose Clasp if: You plan to make frequent changes or prefer command-line workflows
Choose Manual if: You want zero setup complexity and simple copy-paste deployment
- Activity Description (required): Detailed description of the behavior or activity
- Energy Impact (1-10): Rate from "Very Draining" to "Very Filling"
- Wealth Types: Select affected areas (Physical, Mental, Social, Financial, Time)
- Time Duration (required): How long the activity typically takes
- Frequency (required): How often you engage in this activity
- Time of Day (optional): When the activity usually occurs
The form automatically creates/uses a Google Sheet with columns:
- Timestamp
- Description
- Energy Impact (1-10)
- Wealth Types (comma-separated)
- Time Duration
- Frequency
- Time of Day
This form uses only proven Google Apps Script patterns:
✅ Google Apps Script function calls - Direct server-side function invocation
✅ google.script.run API - Prevents blank page navigation issues
✅ Server-side Google Sheets API - Direct sheet writing without external APIs
✅ Simple vanilla JavaScript - No ES6 modules or modern APIs that fail in GAS
✅ Inline event handlers - Reliable event handling in GAS sandbox
✅ Properties Service - Persistent configuration storage
❌ Modern fetch() API - unreliable in GAS sandbox
❌ Complex event listeners - often fail in GAS environment
❌ ES6 modules - not supported in GAS HTML service
❌ External API calls - unnecessary and unreliable
❌ Modern JavaScript frameworks - too complex for GAS
- Robust error handling with detailed logging
- Input validation with length limits and required field checks
- Automatic spreadsheet creation if none exists
- Fallback spreadsheet logic if access issues occur
- Properties Service integration for configuration persistence
- Rate limiting with 1-second cooldown using Script Properties
- Helper functions for testing and spreadsheet management
This application uses Google Apps Script's Properties Service for persistent storage:
// Store last submission timestamp to prevent spam
PropertiesService.getScriptProperties().setProperty('lastSubmission', now.toString());
const lastSubmission = PropertiesService.getScriptProperties().getProperty('lastSubmission');// Store and retrieve the target spreadsheet ID
PropertiesService.getScriptProperties().setProperty('SPREADSHEET_ID', spreadsheetId);
let spreadsheetId = PropertiesService.getScriptProperties().getProperty('SPREADSHEET_ID');Properties Stored:
SPREADSHEET_ID- ID of the Google Sheet used for data storagelastSubmission- Timestamp of last form submission for rate limiting
To configure the form to use your existing Google Sheet instead of creating a new one:
-
Get your Sheet ID from the URL:
https://docs.google.com/spreadsheets/d/1ABC123xyz.../edit ^^^^^^^^^^^ This is your Sheet ID -
Set the Script Property in Google Apps Script:
- Open your Apps Script project
- Go to Project Settings (gear icon)
- Scroll to Script Properties
- Click Add script property
- Property:
SPREADSHEET_ID - Value:
1ABC123xyz...(your actual Sheet ID) - Click Save script property
Alternatively, edit the DEFAULT_SPREADSHEET_ID in code.gs:
const DEFAULT_SPREADSHEET_ID = '1ABC123xyz...'; // Replace with your Sheet IDYour existing sheet should have these column headers (will be added automatically if missing):
- Timestamp | Description | Energy Impact | Wealth Types | Time Duration | Frequency | Time of Day
Benefits:
- ✅ Persistent across script executions
- ✅ Automatic failover if spreadsheet access fails
- ✅ Prevents spam submissions with rate limiting
- ✅ No external database required
- ✅ Uses your existing Google Sheet structure
- Input length limits (500 chars for descriptions)
- Required field validation with user feedback
- XSS prevention through proper input handling
- Form sanitization before submission
- Parameter validation in
addRow() - Data type checking and conversion
- Error logging for debugging
- Safe spreadsheet operations
-
Form goes to blank page:
- ✅ Fixed: Uses google.script.run API for seamless submission
-
Submit button doesn't work:
- ✅ Fixed: Uses Google Apps Script function calls + inline handlers
-
No data in spreadsheet:
- Check Google Apps Script execution logs
- Verify deployment permissions (Execute as: Me, Access: Anyone)
- Check your Google Drive for "Behavior Log Data" spreadsheet
-
Permission errors:
- Make sure Google Apps Script has Google Sheets API access
- Redeploy and reauthorize if needed
This form succeeds where others fail because it:
- Follows Google Apps Script limitations instead of fighting them
- Uses only proven patterns that work reliably in the GAS environment
- Eliminates modern JavaScript that breaks in GAS sandbox
- Provides reliable form submission with google.script.run API
- Handles all edge cases with proper error handling and fallbacks
- Fork the repository
- Make changes directly to
code.gsand/orindex.html - Test deployment in Google Apps Script
- Submit pull request
- All changes must work in Google Apps Script environment
- Test deployments before submitting changes
- Maintain compatibility with proven GAS patterns
- Update documentation when changing functionality
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Deployment Help: See deployment section above for detailed instructions
- Google Apps Script Docs: developers.google.com/apps-script
- Frontend: Vanilla JavaScript, HTML5, CSS3 (GAS-compatible)
- Backend: Google Apps Script (V8 runtime)
- Storage: Google Sheets API
- Architecture: Simple, reliable GAS patterns
- Deployment: Direct file copying (no build process)
Reliable behavior tracking with proven Google Apps Script deployment! 🎯