This open-source repository provides a Google Apps Script solution for automating the handling of Google Ads lead form submissions. The script validates incoming webhook requests, stores lead data in a Google Sheet, and sends email notifications when a new lead is received.
- Validates webhook keys to ensure secure data transmission.
- Stores lead form submissions in a specified Google Sheet.
- Sends email notifications with lead details.
- Supports dynamic fields for easy customisation.
This script captures the following fields from the incoming Google Ads lead form submissions:
- Full Name (
FULL_NAME
): The full name of the lead. - Email (
EMAIL
): The lead's email address. - Phone Number (
PHONE_NUMBER
): The lead's phone number. - Street Address (
STREET_ADDRESS
): The lead's street address. - Postcode (
POSTAL_CODE
): The lead's postal code. - Job Details (
could_you_provide_more_details_about_your_requirements?
): Additional details provided by the lead in response to qualifying questions. - Submission Date: Automatically captures the current date and time of submission.
- A Google Ads account with lead form extensions set up.
- A Google Sheet to store the lead data.
- Google Apps Script access for deployment.
Clone the repository to your local machine:
git clone https://github.com/your-username/google-ads-lead-webhook.git
- Open your Google Sheet.
- Go to Extensions > Apps Script.
- Copy the script from
script.gs
in this repository and paste it into the Apps Script editor.
- Replace the
expectedKey
variable with your actual webhook key. - Replace the Google Sheet ID and email address in the script with your details.
- Click Deploy > New Deployment.
- Choose Web App.
- Set the access permissions to Anyone with the link.
- Use the Web App URL as the webhook URL in Google Ads.
- Add the webhook key as a query parameter.
The script is designed to handle dynamic fields based on the column IDs provided by Google Ads. To modify or add new fields:
-
Identify Column IDs:
- The
user_column_data
object contains all fields from the lead form. - Each field has a
column_id
(e.g.,FULL_NAME
,EMAIL
).
- The
-
Update the Script:
- Locate the
getField
function in the script:const getField = (id) => { const field = userColumnData.find((item) => item.column_id === id); return field ? field.string_value : ''; };
- Add or update the
getField
calls with the appropriatecolumn_id
for your new or updated fields.
- Locate the
- Google Ads Lead Form Extensions Overview: Learn more about importing Lead Form Submission Data using Google Ads API.
- Google Apps Script Documentation: Detailed documentation for working with Apps Script.
- SpreadsheetApp Class: Documentation for interacting with Google Sheets in Apps Script.
- MailApp Class: Guide for sending email notifications in Apps Script.
By following these resources, users can easily adapt the script to capture additional fields or modify existing ones.
This project is licensed under the MIT License.
If you find this project helpful, consider sponsoring us to support future development.
Contributions are welcome! Please follow the guidelines in the CONTRIBUTING.md.
For any issues or questions, please create an issue or reach out via email at [email protected]
.