marshmallow/google-ads-lead-extension

This package will help you handle leads that come in from Google Ads Leads Extension.

v2.0.2 2020-06-11 16:40 UTC

README

68747470733a2f2f63646e2e6d617273686d616c6c6f772d6f66666963652e636f6d2f6d656469612f696d616765732f6c6f676f2f6d617273686d616c6c6f772e7472616e73706172656e742e7265642e706e67

Issues Forks Stars License

Google Ads Lead Extension

This module will make it very easy to handle leads that come in from the Lead Extension in Google Ads. You will be able to do whatever you want to do with the data that is sent to you by Google Ads.

Installing

composer require marshmallow/package-google-ads-lead-extension

Run the installer so everything is setup correctly

php artisan googleads:install-lead-extension

The installer will generate a Google Key for you. This will be shown in your console while running the installer. You will need this key for setting up your lead extension. This key will be used to validate the request is allowed. If you've lost your key, we store the generated key in your .env file so you can always find it there under GOOGLE_ADS_LEAD_EXTENTION_KEY=....

Make sure Google Ads can reach you!

Update your App\Http\Middleware\VerifyCsrfToken.php file so Google will be allowed to do a POST request to your system.

<?php namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
  protected $except = [
    ...
    config('google-ads-lead-extension.prefix') . '/*',
  ];
}

Set up the notifier

By default this package will sent you an email when a new lead is available. The only thing you need to do is adding your emailaddress to the config. Go to the config file config/google-ads-lead-extension.php and setup your emailadress.

<?php

return [

    ...
    /**
     * Emailaddress where new leads will be mailed to.
     */
    'conversion-email-address' => 'INSERT YOUR EMAILADDRESS HERE',
    ...
    
];

Do your magic with the lead

After you've run the installer and made sure Google can reach this URL by making the nessesary adjustments in VerifyCsrfToken.php you are ready to work your magic. The installer has generated a new class in you app directory. You can find this class in app/GoogleAdsLeadExtension.php. This class has 2 methods for you to work with.

handle()

In this method you can do what you need to do with the available data. The available methods to retreive data from the Lead are available in the documentation in the app/GoogleAdsLeadExtension.php file. Use this function to add to lead to your database, to your CRM. What ever you need.

Method Description
$this->getLeadId() Unique ID generated by Google Ads.
$this->getClickId() The Google Ads Click ID if available.
$this->getGclId() The same as getClickId(), just a different name.
$this->getFormId() The form id in your Google Ads account.
$this->getCampaignId() Your Google Ads Campaign ID.
$this->getApiVersion() The API version used by the Google Ads Extension.
$this->isTest() Is it a test request by Google or a real one.
$this->getFullName() Get the name provided by the user.
$this->getPhoneNumber() Get the phonenumber provided by the user.
$this->getEmail() Get the emailaddress provided by the user.
$this->getPostalCode() Get the postalcode provided by the user.

notify()

This method is commented out. This is because we have a default notify method available which will sent you an email with the lead data. If you want to change this behaviour, you can uncomment the notify method and work your own magic.