This document explains how to set up Google Apps Script so your Google Sheet can automatically send data into CDP whenever certain cells are updated or when a new row is added.
You will use a simple trigger (onEdit) to automatically run a script whenever a cell in your Google Sheet is edited. This allows the system to detect changes in specific columns or detect new rows, then send an event to your API/webhook.
1. Open the Apps Script Editor
In your Google Sheet, go to Extensions in the top menu.
Select Apps Script.
A new tab will open with the Apps Script code editor.
2. Write Your Apps Script
Replace the existing content in Code.gs with the script below.
3. Create a trigger for onEdit
In the Apps Script editor, open the left sidebar and click Triggers (⏰ icon).
Click the “+ Add Trigger” button in the bottom-right corner.
In the popup, configure:
Choose which function to run: onEdit
Choose which deployment should run: Head
Select event source: From spreadsheet
Select event type: On edit
Click Save.
From now on, every time a user edits the sheet:
Google Sheets fires the on edit event.
The trigger calls your onEdit(e) function.
Your script checks which row/column changed and decides whether to send an event to your API/CDP.
4. Verify that everything works
Go back to your Google Sheet.
Edit one of the columns that your script is watching (for example: update a status or tick a payment checkbox).
Return to Apps Script → Executions (left sidebar):
Check that there is a new successful run of onEdit.
Check log in CDP
Verify that the event was received with the correct row data.