Home›Blog›AI Automation
AI Automation

Log GoHighLevel Leads to Google Sheets With a Webhook and Apps Script

A free, reliable way to copy GoHighLevel leads into Google Sheets: a Custom Webhook action, a short Apps Script and a secret check.
Saleem Akhter
5 min read

Plenty of businesses still want a spreadsheet. The owner checks it on a phone, the accountant sorts it, the marketing contractor builds a chart from it. Copying leads in by hand is exactly the kind of job GoHighLevel should do for you.

This guide shows how to send GoHighLevel to Google Sheets without a paid connector: a Custom Webhook action in a workflow posts each lead to a small Google Apps Script, which adds a row. It takes about fifteen minutes, costs nothing beyond your normal workflow usage, and includes a simple secret check so random requests cannot write to your sheet.

What you will build

  1. A Google Sheet with a header row.
  2. An Apps Script web app that accepts a POST request and appends a row.
  3. A GoHighLevel workflow step that sends the lead’s details to that web app.

Step 1: prepare the sheet

Create a new Google Sheet and name the first tab Leads. Add these headers in row 1:

Received at | First name | Last name | Email | Phone | Source | Tags | Contact ID

Step 2: add the Apps Script

In the sheet, open Extensions → Apps Script, delete the sample code and paste the script below. Replace the secret with a long random string of your own.

// Shared secret: the same value goes in the GoHighLevel webhook body.
const SECRET = 'replace-with-a-long-random-string';
const SHEET_NAME = 'Leads';

function doPost(e) {
  let data;
  try {
    data = JSON.parse(e.postData.contents);
  } catch (err) {
    return reply({ ok: false, error: 'Invalid JSON' });
  }

  if (data.secret !== SECRET) {
    return reply({ ok: false, error: 'Unauthorised' });
  }

  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME);
  const lock = LockService.getScriptLock();
  lock.waitLock(10000); // stop two leads writing to the same row at once
  try {
    sheet.appendRow([
      new Date(),
      data.first_name || '',
      data.last_name || '',
      data.email || '',
      data.phone ? "'" + data.phone : '', // keep the leading + on phone numbers
      data.source || '',
      data.tags || '',
      data.contact_id || '',
    ]);
  } finally {
    lock.releaseLock();
  }
  return reply({ ok: true });
}

function reply(obj) {
  return ContentService.createTextOutput(JSON.stringify(obj))
    .setMimeType(ContentService.MimeType.JSON);
}

Two small details make this reliable. The lock stops two leads arriving at the same moment from overwriting each other, and the apostrophe before the phone number stops Sheets from treating +44… as a formula or dropping the leading plus.

Step 3: deploy the script as a web app

  1. Click Deploy → New deployment and choose the type Web app.
  2. Set Execute as to Me and Who has access to Anyone. The secret check is what protects the sheet.
  3. Authorise the script when Google asks, then copy the Web app URL ending in /exec.
Changed the code later? Apps Script keeps serving the old version until you publish a new version of the same deployment (Deploy → Manage deployments → Edit → New version). Creating a brand-new deployment gives you a different URL.

Step 4: add the webhook to a GoHighLevel workflow

  1. Open the workflow that handles new leads — for example one triggered by a form submission.
  2. Add the Custom Webhook action and choose the custom mode so you can send a JSON body.
  3. Set the method to POST, paste the web app URL, and set the content type to application/json.
  4. Build the body with contact merge fields from the field picker, plus your secret:
{
  "secret": "replace-with-a-long-random-string",
  "first_name": "{{contact.first_name}}",
  "last_name": "{{contact.last_name}}",
  "email": "{{contact.email}}",
  "phone": "{{contact.phone}}",
  "source": "{{contact.source}}",
  "tags": "{{contact.tags}}",
  "contact_id": "{{contact.id}}"
}

Insert the merge fields with GoHighLevel’s own picker rather than typing them, so they exactly match what your account offers. If a field is not available, leave it out of the body and remove the matching column from the script.

Step 5: test it

  1. Use the workflow’s test option, or submit the form yourself.
  2. Check that a new row appears in the sheet within a few seconds.
  3. If nothing arrives, open the workflow’s execution log; it shows the response from the web app.
  4. Send one request with a wrong secret to confirm the script rejects it.

Troubleshooting

SymptomCauseFix
Response is “Unauthorised”The secret in the body does not match the scriptCopy the same value into both places
Response is an HTML pageThe deployment is not shared with “Anyone”Edit the deployment’s access setting
Rows appear but some cells are emptyKey names differ between the body and the scriptMatch first_name, email and so on exactly
Script changes have no effectThe deployment still serves the old versionPublish a new version of the existing deployment
Phone numbers lose the + signSheets treats them as numbersKeep the apostrophe prefix shown in the script

Ideas for extending it

  • One tab per source. Pass a tab value in the body and use it instead of the fixed sheet name.
  • Update instead of append. Search the Contact ID column and update the existing row when a lead changes stage.
  • Pipeline log. Trigger the webhook from opportunity stage changes to build a simple sales history.
  • Client reporting. Feed the sheet into a chart or dashboard — see our client reporting guide.

Privacy

A spreadsheet is easy to share by accident. Keep the sheet’s sharing settings tight, send only the fields you need, and do not use this pattern for sensitive data such as health or financial details. If the secret is ever exposed, change it in both the script and the workflow.

For two-way syncing or larger volumes, call the API instead — see our GoHighLevel API guide. For no-code connectors, our Zapier and Make guide compares the options.

Frequently asked questions

Does this cost anything?

Google Apps Script is free within Google’s usage quotas. In GoHighLevel, the Custom Webhook action may count as a premium workflow action depending on your plan.

Is “Anyone” access safe?

The URL is long and unguessable, and the script ignores any request without the correct secret. That is adequate for lead logging; it is not designed for sensitive data.

Can I send older contacts too?

Yes. Add the contacts to the workflow in bulk, or export them once as a CSV and paste them into the sheet.

What happens if the tab is renamed?

The script looks for the tab by name, so update SHEET_NAME if you rename it.

Ready to Implement This?

Let GHL Nexa set this up for you. Book a free 30-minute strategy call today.

SHARE THIS ARTICLE