PHPackages                             zenthicmc/laravel-google-ads - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. zenthicmc/laravel-google-ads

ActiveLibrary[API Development](/categories/api)

zenthicmc/laravel-google-ads
============================

Google Adwords API for Laravel

v3.0.2(1y ago)02MITPHP

Since Nov 4Pushed 1y agoCompare

[ Source](https://github.com/zenthicmc/laravel-google-ads)[ Packagist](https://packagist.org/packages/zenthicmc/laravel-google-ads)[ RSS](/packages/zenthicmc-laravel-google-ads/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (15)Used By (0)

Google Adwords API for Laravel
==============================

[](#google-adwords-api-for-laravel)

Simple and easy to use API for your Google Adwords.

Installation
------------

[](#installation)

##### Type in console:

[](#type-in-console)

```
composer require zenthicmc/laravel-google-ads

```

##### Laravel 5.5 or higher?

[](#laravel-55-or-higher)

Then you don't have to either register or add the alias, this package uses Package Auto-Discovery's feature, and should be available as soon as you install it via Composer.

##### (Only for Laravel 5.4 or minor) Register the GoogleAds service by adding it to the providers array.

[](#only-for-laravel-54-or-minor-register-the-googleads-service-by-adding-it-to-the-providers-array)

```
'providers' => array(
        ...
        Edujugon\GoogleAds\Providers\GoogleAdsServiceProvider::class
    )

```

##### (Only for Laravel 5.4 or minor) Let's add the Alias facade, add it to the aliases array.

[](#only-for-laravel-54-or-minor-lets-add-the-alias-facade-add-it-to-the-aliases-array)

```
'aliases' => array(
        ...
        'GoogleAds' => Edujugon\GoogleAds\Facades\GoogleAds::class,
    )

```

##### Publish the package's configuration file to the application's own config directory.

[](#publish-the-packages-configuration-file-to-the-applications-own-config-directory)

```
php artisan vendor:publish --provider="Edujugon\GoogleAds\Providers\GoogleAdsServiceProvider" --tag="config"

```

The above command will generate a new file under your laravel app config folder called `google-ads.php`

Configuration
-------------

[](#configuration)

Update the `google-ads.php` file with your data.

```
'env' => 'test',
'production' => [
    'developerToken' => "YOUR-DEV-TOKEN",
    'clientCustomerId' => "CLIENT-CUSTOMER-ID",
    'userAgent' => "YOUR-NAME",
    'clientId' => "CLIENT-ID",
    'clientSecret' => "CLIENT-SECRET",
    'refreshToken' => "REFRESH-TOKEN"
],
'test' => [
    'developerToken' => "YOUR-DEV-TOKEN",
    'clientCustomerId' => "CLIENT-CUSTOMER-ID",
    'userAgent' => "YOUR-NAME",
    'clientId' => "CLIENT-ID",
    'clientSecret' => "CLIENT-SECRET",
    'refreshToken' => "REFRESH-TOKEN"
],

```

> 'env' key accepts one of the following values: test / production

Generate refresh token
----------------------

[](#generate-refresh-token)

> Notice that it will take the `clientID` and `clientSecret` from `google-ads.php` config file based on the `env` value.

Type in console:

```
php artisan googleads:token:generate

```

- Visit the URL it shows, grant access to your app and input the access token in console.
- Then copy the fresh token in `google-ads.php` config file.

> Remember to copy that token in the correct section (test/production).Depends on your `env` value.

Usage samples
-------------

[](#usage-samples)

Instance the main wrapper class:

```
$ads = new GoogleAds();

```

> Do not forget to put at the top of the file the use statement:

```
use Edujugon\GoogleAds\GoogleAds;

```

All needed configuration data is took from `google-ads.php` config file. But you always may pass new values on the fly if required.

You may override the default environment value calling the env method:

```
$ads->env('test');

```

Also, you may get the env value by getEnv method:

```
$ads->getEnv();

```

If need to override the oAuth details, just call the oAuth method like so:

```
$ads->oAuth([
            'clientId' => 'test',
            'clientSecret' => 'test',
            'refreshToken' => 'TEST'

        ]);

```

Same with session. If need to override the default values on the fly, just do it by calling session method:

```
$ads->session([
    'developerToken' => 'token',
    'clientCustomerId' => 'id'
]);

```

All the above methods can be chained as follows:

```
$ads->env('test')
    ->oAuth([
        'clientId' => 'test',
        'clientSecret' => 'test',
        'refreshToken' => 'TEST'

    ])
    ->session([
        'developerToken' => 'token',
        'clientCustomerId' => 'id'
    ]);

```

### Google Services

[](#google-services)

For Google Ads Services you only have to call the service method:

```
$ads->service(CampaignService::class);

```

or

```
$ads->service(AdGroupService::class);

```

or

```
$ads->service(AdGroupAdService::class);

```

or Any google ads services available under `Google\AdsApi\AdWords\v201809\cm` folder.

Also you can use the global helper in order the get an instance of Service.

```
$service = google_service(CampaignService::class)

```

To retrieve a list of campaigns, do like follows:

```
$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->get();

```

> Notice the method `select` is required and you have to use it in order to set the fields you wanna get from the campaign.

If need to add a condition to your search you can use the `where` method like follows:

```
$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->where('Id IN [752331963,795625088]')
    ->get();
or

$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->where('Id = 752331963')
    ->get();

```

> Notice! You may also set more than one condition. Do so calling `where` method as many times as you need.

Available Operators:

```
= | != | > | >= | < | service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->limit(5)
    ->get();

```

Also you can order by a field:

```
$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->orderBy('Name')
    ->limit(5)
    ->get();

```

Notice that the `get` method returns an instance of ServiceCollection. That custom collection has its own methods.

Once you have the collection, you can again filter with the where method

```
$campaignService = $ads->service(CampaignService::class);

$results = $campaignService->select('CampaignId','CampaignName')->get();

//You can also add any where condition on the list.
$campaign = $results->where('id',1341312);

```

Also you can call the `set` method to change any value

```
$campaign = $results->where('id',$this->testedCampaignId)->set('name','hello !!');

```

Finally you can persist those changes with the `save` method:

```
$campaign = $campaign->save();

```

Save method returns an array of updated elements or false if nothing updated.

> Important!! notice that it will persist all elements that are in the collection.

You can get the list as illuminate collection simply calling `items` method.

### Google Reports

[](#google-reports)

To start with google reporting just call `report` method from the main wrapper:

```
$report = $ads->report();

```

or use the global helper like follows:

```
$report = google_report();

```

It will return an instance of `Edujugon\GoogleAds\Reports\Report`

Now, you have a set of method to prepare the google ads report:

```
$obj = $ads->report()
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->during('20170101','20170210')
            ->where('CampaignId = 752331963')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->getAsObj();

```

In the above methods, the mandatory ones are `from` and `select`

> Notice that in `during` method you have to pass the dates as a string like YearMonthDay

You may also want to set more than one condition. Use Where clause as many times as you need like follows:

```
$obj = $ads->report()
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->where('Clicks > 10')
            ->where('Cost > 10')
            ->where('Impressions > 1')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->getAsObj();

```

Available Operators:

```
= | != | > | >= | < | report()
           ->from('SHOPPING_PERFORMANCE_REPORT')
           ->select(\Edujugon\GoogleAds\Facades\GoogleAds::fields()->of('SHOPPING_PERFORMANCE_REPORT')->asList())
           ->except('SearchImpressionShare','ExternalConversionSource','Ctr','Cost','Date','Week','Year','AverageCpc','Clicks','ClickType','ConversionCategoryName','ConversionTrackerId','ConversionTypeName')
            ->getAsObj();

```

If want to see the retrieve items, just get so by `result` property of the object returned:

```
$items = $obj->result;

```

> Notice that it is a Collection. So you have all collection methods available.

If need the report in another format, just call `format` method before getting the report:

```
$string = $ads->report()
            ->format('CSVFOREXCEL')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->getAsString();

```

To see the available report formats:

```
$ads->report()->getFormats()

```

To see what fields are available for a specific report type you can do like follows:

```
$fields = $ads->report()->from('CRITERIA_PERFORMANCE_REPORT')->getFields();

```

If want to know what report types are available, just do like follow:

```
$ads->report()->getTypes();

```

There are 3 output formats for the report. It can be as object, as stream, as string.

```
getAsString();
getStream();
getAsObj();

```

Also you can save the report in a file:

```
$saved = $ads->report()
             ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
             ->from('CRITERIA_PERFORMANCE_REPORT')
             ->saveToFile($filePath)

```

> The above code will create a file in the passed path returning true if everything was fine.

API Documentation
-----------------

[](#api-documentation)

[Full API List](https://edujugon.github.io/laravel-google-ads/build/master/Edujugon/GoogleAds/GoogleAds.html)

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance47

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 94.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~208 days

Recently: every ~459 days

Total

14

Last Release

399d ago

Major Versions

1.6.2 → 2.0.02019-09-08

2.2.0 → v3.0.02025-04-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b1c5ad0022f76be186c3e50c6812cc7b22e7bc26aaa29b22ce56e71bf426ad7?d=identicon)[zenthicmc](/maintainers/zenthicmc)

---

Top Contributors

[![Edujugon](https://avatars.githubusercontent.com/u/4853751?v=4)](https://github.com/Edujugon "Edujugon (129 commits)")[![zenthicmc](https://avatars.githubusercontent.com/u/43224845?v=4)](https://github.com/zenthicmc "zenthicmc (5 commits)")[![JeremyDunn](https://avatars.githubusercontent.com/u/161614?v=4)](https://github.com/JeremyDunn "JeremyDunn (1 commits)")[![LTKort](https://avatars.githubusercontent.com/u/2412670?v=4)](https://github.com/LTKort "LTKort (1 commits)")

---

Tags

laraveladsgoogleadwords

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zenthicmc-laravel-google-ads/health.svg)

```
[![Health](https://phpackages.com/badges/zenthicmc-laravel-google-ads/health.svg)](https://phpackages.com/packages/zenthicmc-laravel-google-ads)
```

###  Alternatives

[edujugon/laravel-google-ads

Google Adwords API for Laravel

66424.7k](/packages/edujugon-laravel-google-ads)[spotonlive/laravel-google-ads

Google Ads API for Laravel

6391.1k](/packages/spotonlive-laravel-google-ads)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[thujohn/analytics

Google Analytics for Laravel 4

113108.7k1](/packages/thujohn-analytics)[neuron-core/neuron-laravel

Official Neuron AI Laravel SDK.

10710.0k](/packages/neuron-core-neuron-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
