STEP 1
Create Google Sheet
Open Google Sheets and create a new blank spreadsheet. Name column A Email and column B Timestamp.
STEP 2
Open Apps Script & Paste Code
Click Extensions > Apps Script in your Google Sheet top menu. Clear any existing code and paste this snippet:
function doPost(e) {
try {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = JSON.parse(e.postData.contents);
var email = data.email;
var timestamp = new Date();
sheet.appendRow([email, timestamp]);
return ContentService.createTextOutput(JSON.stringify({ "result": "success" }))
.setMimeType(ContentService.MimeType.JSON);
} catch (error) {
return ContentService.createTextOutput(JSON.stringify({ "result": "error", "error": error.toString() }))
.setMimeType(ContentService.MimeType.JSON);
}
}
STEP 3
Deploy as Web App
- Click Deploy > New deployment at top right.
- Click gear icon next to "Select type" and choose Web app.
- Set Execute as: Me.
- Set Who has access: Anyone (Crucial!).
- Click Deploy and copy the Web App URL.