First you should create a Google ads search campaign to see Ads & Extensions menu on left.

After that click on,

Ads & Extensions -> Extensions -> Add “Lead Form Extension” (Beta)

Select form fields, fill the empty fields like call-to-action, URL, etc.

You will find a section “Webhook integration (optional)” to enter Webhook URL and Key.

First create a page on your website webhook.php and enter following code in it:

<?php

$Google_data = file_get_contents("php://input");
$decoded_data= json_decode($Google_data, true);

$pass="key_for_webhook";

if ( $pass == $decoded_data["google_key"]){

    $lead_id = $decoded_data["lead_id"];
    
    $campaign_id = $decoded_data["campaign_id"];
    
    $bodyemail .= "Name: " . $decoded_data["user_column_data"][0]["string_value"];
    
    $bodyemail .= "<br>Phone: "  . $decoded_data["user_column_data"][1]["string_value"];
    
    $bodyemail .= "<br>Email: " . $decoded_data["user_column_data"][2]["string_value"];

}

$bodyemail .= "<br>Campagin ID: ". $campaign_id;

$bodyemail .= "<br>lead ID: ". $lead_id;

$emailfrom = "admin@wordpress.com";

$emailto = "your_email@example.com";

$subject = "Google Ads | Lead form extension";

$headers = "MIME-Version: 1.0" . "\r\n";

$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

$headers .= 'From: <webmaster@example.com>' . "\r\n";

$headers .= 'Cc: second_email@example.com' . "\r\n";

mail($emailto, $subject, $bodyemail, $headers);

?>

You can enter your emails where you want to send data, in above code.

Now your Webhook URL is: https://www.your-website-name.com/webhook.php

Your Key is: key_for_webhook

 

Contact for any tasks related to Google code or Google services setup.