This guide explains how to capture data changes in your Google Sheet and automatically send them to Ours Privacy using Google Apps Script. This is especially useful if you need to track conversions or other key events from your internal data and push them to your ad and analytics platforms.

For more details on the API, check out the Ours Privacy API documentation here.


Overview

In this example, you'll learn how to create an "On Edit" trigger. The trigger monitors a specific sheet and column in your Google Sheet. When a change occurs, it extracts the row's data and sends an event (such as a conversion) to the Ours Privacy API. This process automates your data flows and ensures that key events are accurately captured and forwarded.

A sample Google Sheet is available for reference here, and you can watch a brief demo video below.

Sample file: https://docs.google.com/spreadsheets/d/1Uo4je04947P3-LPSbkyqKBHRn6Q71fOARdSJ1ya-AqY/edit?usp=sharing

Step 1: Open Google Apps Script

Accessing the Apps Script editor lets you create custom logic that listens for changes in your data.

  1. Open your Google Sheet where you want the trigger to run.
  2. Click ExtensionsApps Script.
  3. This opens the Google Apps Script Editor—a platform for writing custom scripts that monitor your sheet.

Step 2: Add the Script

This script monitors a specific sheet and column. When an edit occurs, it gathers the relevant row data and sends a POST request to the Ours Privacy API. Replacing 'YOUR TOKEN HERE' with your actual token ensures the event is authenticated and connected to your Ours Privacy account.

  1. In the Apps Script Editor, delete any existing code.
  2. Copy and paste the sample script below. Adjust the variable names as needed:

Step 3: Set Up an Installable Trigger

The installable trigger ensures that your script automatically runs whenever someone edits the designated column. Granting OAuth permissions lets your script securely communicate with the Ours Privacy API.

  1. In the Apps Script Editor, click the Clock (Triggers) icon in the left panel.