jeffersongoncalves / laravel-linkedin-ads
A lightweight LinkedIn Ads (Marketing API) client for Laravel — list ad accounts, manage campaigns, run analytics reports, list creatives, and estimate audience counts.
Package info
github.com/jeffersongoncalves/laravel-linkedin-ads
pkg:composer/jeffersongoncalves/laravel-linkedin-ads
Requires
- php: ^8.2
- illuminate/support: ^11.0|^12.0|^13.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.21
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel LinkedIn Ads
A lightweight LinkedIn Ads (Marketing API v2) client for Laravel. It wraps ad account listing, campaign management, analytics reporting, creative listing, and audience count estimation behind a small static client, threads your OAuth bearer token, and returns null sentinels on ordinary HTTP failures instead of throwing.
Features
accounts()— list ad accounts accessible to the configured tokencampaigns()— list campaigns belonging to an ad accountcreateCampaign()— create a new (paused) campaign within a campaign groupupdateCampaignStatus()— update a campaign's status (e.g.ACTIVE,PAUSED,ARCHIVED)campaignAnalytics()— impressions, clicks, cost, and conversions for a campaign over a date rangecreatives()— list creatives belonging to a campaignaudienceCount()— estimate the reachable audience count for a targeting facet set
Installation
composer require jeffersongoncalves/laravel-linkedin-ads
Optionally publish the config file:
php artisan vendor:publish --tag="linkedin-ads-config"
Configuration
Add to your .env:
LINKEDIN_ADS_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxx LINKEDIN_ADS_API_VERSION=v2 LINKEDIN_ADS_TIMEOUT=8
LINKEDIN_ADS_ACCESS_TOKEN is the OAuth bearer token — see the authorization code flow guide. LINKEDIN_ADS_API_VERSION is the Marketing API version segment used in request URLs.
Config Options
// config/linkedin-ads.php return [ 'access_token' => env('LINKEDIN_ADS_ACCESS_TOKEN'), 'version' => env('LINKEDIN_ADS_API_VERSION', 'v2'), 'timeout' => (int) env('LINKEDIN_ADS_TIMEOUT', 8), ];
Usage
use JeffersonGoncalves\LinkedinAds\LinkedinAdsClient; // Ad accounts $accounts = LinkedinAdsClient::accounts(); // Campaigns $campaigns = LinkedinAdsClient::campaigns('123456789'); // Create a campaign (created PAUSED, matching LinkedIn's API default) $campaign = LinkedinAdsClient::createCampaign( accountId: '123456789', campaignGroupId: '987654321', name: 'Q3 Launch', unitCost: 5.00, dailyBudget: 100.00, ); // Toggle a campaign's status LinkedinAdsClient::updateCampaignStatus('111', 'ACTIVE'); // Analytics for a date range $stats = LinkedinAdsClient::campaignAnalytics( campaignId: '111', startYear: 2026, startMonth: 1, startDay: 1, endYear: 2026, endMonth: 1, endDay: 31, ); // Creatives $creatives = LinkedinAdsClient::creatives('111'); // Audience count for a targeting facet set $count = LinkedinAdsClient::audienceCount([ 'include' => [ 'and' => [ ['or' => ['urn:li:adTargetingFacet:locations' => ['urn:li:geo:103644278']]], ], ], ]);
Testing
composer test
Static Analysis
composer analyse
Code Formatting
composer format
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
