Auto-populate timestamp when Zapier adds data to Google Sheets

I have a Google Apps Script that automatically adds today’s date to column B whenever I manually enter data in column A. Here’s my current code:

function onCellEdit() {
  var sheet = SpreadsheetApp.getActiveSheet();
  if (sheet.getName() == "my_data") {
    var cell = sheet.getActiveCell();
    if (cell.getColumn() == 1) {
      var dateCell = cell.offset(0, 1);
      if (dateCell.getValue() === '')
        dateCell.setValue(new Date());
    }
  }
}

This works perfectly when I type data manually into the spreadsheet. However, when Zapier automatically imports data from my project management tool into Google Sheets, the script doesn’t trigger at all. The onEdit trigger only responds to manual changes, not automated ones from external services. How can I modify this to work with Zapier imports? I need the timestamp to appear automatically whenever new rows are added through automation.

I ran into this same headache about six months ago with my inventory tracking setup. The solution that finally worked was creating a custom function in Zapier itself to trigger a Google Apps Script web app. Instead of relying on sheet triggers, I set up a web app function that Zapier calls after it adds the data. The web app receives the row number or range from Zapier and then adds the timestamp to the corresponding cells. You basically need to create a doPost function in your script and deploy it as a web app, then have Zapier make a POST request to that URL with the relevant row information. It requires a bit more setup on both ends, but it’s bulletproof and works every single time. The timestamps appear within seconds of the data import.

yeah, zapier won’t trigger onEdit since it’s not a manual change. u should consider a time-driven trigger to run a function every few minutes to check for rows with no timestamps & fill them in. it’s not perfect, but that’s what many do.

The onEdit trigger limitation with external integrations is a common frustration. I encountered this exact issue when setting up automated data imports from various tools. What worked reliably for me was switching to the onChange trigger instead of onEdit. The onChange trigger fires when the structure of the spreadsheet changes, including when new rows are added by external services like Zapier. You would need to modify your approach slightly - instead of checking for edits in column A, you could scan for new rows that have data in column A but empty timestamps in column B. This method caught all my Zapier imports consistently, though you might need to add some logic to handle bulk imports efficiently.