Lead Form Extension Webhook Emailer

Get notified whenever your lead form extension is filled out.

Start Now!
Lead Form Get started!

This is a simple php script which utilizes the webhook functionality for the Google Ads lead form extension. Whenever a form is filled out you receive an email instead of manually checking or creating a complicated link with your CMS. Instructions:

  1. Add the script below to a php file, e.g. email.php
  2. Upload the php file to your web server, e.g. https://agency.com/email.php
  3. When setting up your lead form extension, use the above URL and add your email address as a parameter e.g. https://agency.com/email.php?email=yourname@agency.com
  4. (You can fill in anything in the key field, e.g. 123)
  5. Use the test functionality, you should receive an email with test data

When a form is filled out you receive an email with the raw JSON data.

Whenever the extension gets more popular, this script will be improved with working key functionality and formatted emails.

The script
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$email = $_GET["email"];

$rawData = file_get_contents('php://input');
$data = json_decode($rawData, true);
$msg = $rawData;

mail($email ,"Google Ads leadform", "Lead: 
" . $msg);

----
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$email = $_GET["email"];

$rawData = file_get_contents('php://input');
$data = json_decode($rawData, true);

$headers = "From: info@agency.com\r\n";
$headers .= "Reply-To: noreply@agency.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

$subject = "Google Ads Leadform";

$message = "
We received the following lead from Google Ads:<br /><br />
Name: " . $data["user_column_data"][0]["string_value"] . "<br />
E-mail address: " . $data["user_column_data"][2]["string_value"] . "<br />
Phone: " . $data["user_column_data"][1]["string_value"];

mail($email ,$subject, $message, $headers);
Show whole script!
The Experts
Tibbe van Asten Head of PPC @ Increase
Nils Rooijmans Water Cooler Topics
Martijn Kraan Freelance PPC Specialist
Bas Baudoin Teamlead SEA @ Happy Leads
How about you? JOIN US!
Sharing Knowledge
Caring

Sharing Knowledge

Adsscripts.com is all about sharing knowledge. In the current market, PPC specialists like to keep their knowledge and experience to themselves. We're convinced that sharing knowledge can ensure that everyone gets better at their work. We want to change this by sharing our knowledge about scripts with everyone.

Do you also want to contribute? We are open to new ideas and feedback on everything you find on Adsscripts.com.

Contact us

Training &
Workshop
Contact us!
Adsscripts Training & Workshop