tmarois / laravel-ads-sdk
A Laravel Ads SDK for Google Ads, Bing Ads and Facebook Ads API
Installs: 60 720
Dependents: 0
Suggesters: 0
Security: 0
Stars: 108
Watchers: 18
Forks: 38
Open Issues: 17
Type:package
Requires
- php: >=7
- facebook/php-business-sdk: ^13.0
- googleads/googleads-php-lib: ^49.0
- microsoft/bingads: ^0.12
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: 6.*
- dev-master
- 1.5.x-dev
- v1.5.0
- 1.4.x-dev
- v1.4.0
- 1.3.x-dev
- v1.3.0
- 1.2.x-dev
- v1.2.23
- v1.2.22
- v1.2.21
- v1.2.20
- v1.2.19
- v1.2.18
- v1.2.17
- v1.2.16
- v1.2.15
- v1.2.14
- v1.2.13
- v1.2.12
- v1.2.11
- v1.2.10
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- 1.1.x-dev
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/npm_and_yarn/cacheable-request-and-release-it-10.2.7
- dev-dependabot/npm_and_yarn/http-cache-semantics-4.1.1
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/qs-6.11.0
- dev-dependabot/npm_and_yarn/minimatch-3.1.2
- dev-dependabot/npm_and_yarn/node-fetch-2.6.7
- dev-dependabot/npm_and_yarn/ansi-regex-4.1.1
- dev-facebook-implement
This package is auto-updated.
Last update: 2024-06-12 22:35:19 UTC
README
Join the Discord – For support, updates and collaboration.
For Google Ads, Bing Ads and Facebook Ads API.
This is a wrapper for connecting each ad source into your Laravel application. This SDK provides a cleaner and a more consistent integration across many ad platforms than the official SDKs, and ultimately making it a lot easier to implement in your projects. You shouldn't have to learn how to communicate and understand the responses to every API.
Installation
Use Composer to install package.
Run composer require tmarois/laravel-ads-sdk
Config
-
Run
php artisan vendor:publish --tag=laravel-ads-sdk
-
Copy this to your
.env
and update with your credentials (if you dont have credentials, continue to the next step).
ADWORDS_DEVELOPER_TOKEN=""
ADWORDS_OAUTH2_CLIENT_ID=""
ADWORDS_OAUTH2_CLIENT_SECRET=""
ADWORDS_OAUTH2_REFRESH_TOKEN=""
BING_DEVELOPER_TOKEN=""
BING_CLIENT_ID=""
BING_CLIENT_SECRET=""
BING_REFRESH_TOKEN=""
FB_APP_ID=""
FB_APP_SECRET=""
FB_ACCESS_TOKEN=""
FB_REFRESH_TOKEN=""
Authentication
👉 For GoogleAds
You will need your developer token, client id and client secret to continue. Learn More
Follow the steps in the command line to generate a refresh token.
Run php artisan laravelads:token:generate --service=GoogleAds
Having Trouble? Learn More
👉 For BingAds
You will need your developer token, client id and client secret to continue. Learn More
Follow the steps in the command line to generate a refresh token.
Run php artisan laravelads:token:generate --service=BingAds
Having Trouble? Learn More
👉 For FacebookAds
You will need your app id, app secret and access token. Learn More
NOTE: It appears for facebook, you do not need to generate refresh token, once you have your access token, the api should connect as long as you've given yourself the correct access, permissions, scopes to marketing api and ads account.
🚀 Usage
Accessing GoogleAds
, BingAds
or FacebookAds
use the following:
// The namespace to the Facade for laravel Ads SDK use LaravelAds; // calling Google Ads and including the Account ID $googleAds = LaravelAds::googleAds()->with('ACCOUNT_ID'); // calling Bing Ads and including the Account ID $bingAds = LaravelAds::bingAds()->with('ACCOUNT_ID'); // calling Facebook Ads and including the Account ID $facebookAds = LaravelAds::facebookAds()->with('ACCOUNT_ID');
Google Ads
This uses the googleads-php-lib SDK for the Google Ads API
NOTICE – You will need to Request Google Ads API Access.
Need help with authentication?
Management
- Fetching - All Campaigns
- Fetching - All Ad Groups
- Management - Campaigns
- Management - Ad Groups
- Offline Conversion Import
- Manual Configuration
- Advanced Options
Reports
- Account Performance
- Campaign Performance
- Ad Group Performance
- Final URL Performance
- Placement Domain Performance
- Placement URL Performance
- Search Term Performance
- Age Range Performance
- Gender Performance
Bing Ads
This uses the BingAds-PHP-SDK for the Bing Ads API
NOTICE – You will need to Request Bing Ads API Access.
Need help with authentication or sandbox mode?
Management
- Fetching - Get Customers
- Fetching - All Campaigns
- Fetching - All Ad Groups
- Management - Campaigns
- Management - Ad Groups
- Offline Conversion Import
- Manual Configuration
Reports
- Account Performance
- Campaign Performance
- Ad Group Performance
- Final URL Performance
- Search Term Performance
- Age Range Performance
- Gender Performance
- Custom Fields
Facebook Ads
This uses the facebook-php-business-sdk for Facebook Marketing API
Management
Reports
Customization
We realize that we can't add every endpoint so in order to help improve your developer experience, we have made the Service classes Macroable. Macros are a way to add a new custom method to the classes. This way you are able to utilize the existing auth and all of the other goodies that come with this package.
Typically, you should call this method from the boot method of one of your application's service providers, such as the App\Providers\AppServiceProvider
service provider:
public function boot() { LaravelAds\Services\BingAds\Service::macro('addUetTags', function($tags){ $serviceCall = $this->call(ServiceClientType::CampaignManagementVersion13); try { $request = new AddUetTagsRequest(); $request->UetTags = $tags; $serverResponse = $serviceCall->GetService()->AddUetTags($request); return $serverResponse; } catch (\Exception $e) { print $serviceCall->GetService()->__getLastRequest()."\n"; print $serviceCall->GetService()->__getLastResponse()."\n"; } }); LaravelAds\Services\GoogleAds\Service::macro('dd', function(){ dd($this); }); }
Then in your controller or job you would call:
$bingAds = LaravelAds::bingAds()->addUetTags([ [ 'Name' => 'Extensible!', 'Description' => 'No PR Needed!', ] ]); $bingAds = LaravelAds::googleAds()->dd();
Contributions
We are actively looking for new contributors.
If you want to contribute, Join the Discord channel and/or submit pull requests.
License
Laravel Ads SDK (This Package) is open-sourced software licensed under the MIT license. USE AT YOUR OWN RISK. Laravel Ads SDK is a tool to help you manage your accounts, it does not guarantee features listed here will work as described. If you do find a bug, please feel free to submit an issue. This package is not affiliated with Laravel LLC or the Laravel Framework team.