jeffersongoncalves / laravel-adobe-analytics
PHP/Laravel client for the Adobe Analytics 2.0 REST API: report suites, dimensions, metrics, segments and report runs, with OAuth Server-to-Server token handling built in.
Package info
github.com/jeffersongoncalves/laravel-adobe-analytics
pkg:composer/jeffersongoncalves/laravel-adobe-analytics
Fund package maintenance!
Requires
- php: ^8.2
- illuminate/http: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.7.4|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel Adobe Analytics
A PHP/Laravel client for the Adobe Analytics 2.0 REST API. Covers report suites, dimensions, metrics, segments and report runs through a simple, typed API built on Laravel's Http client, with OAuth Server-to-Server (client_credentials) token acquisition and caching handled for you.
Features
- Report suites: list all report suites available to your company
- Dimensions and metrics: list the available dimensions/metrics for a report suite
- Segments: list segments, optionally filtered by report suite
- Reports: run a report for a date range, a set of metrics and an optional dimension
- OAuth Server-to-Server (
client_credentials) token acquisition, cached automatically and refreshed on expiry - Optional static
access_tokenoverride that skips the OAuth flow entirely (handy for testing or when a token is already managed elsewhere) - Throws
AdobeAnalyticsException(with the original API error body) on any non-2xx response
Installation
You can install the package via composer:
composer require jeffersongoncalves/laravel-adobe-analytics
Publish the config file:
php artisan vendor:publish --tag=adobe-analytics-config
Using OAuth Server-to-Server (recommended)
Create a Server-to-Server OAuth credential in the Adobe Developer Console for the Adobe Analytics API, then set:
ADOBE_CLIENT_ID=your-client-id ADOBE_CLIENT_SECRET=your-client-secret ADOBE_COMPANY_ID=your-global-company-id
The package will exchange these credentials for an access token on first use, cache it, and transparently fetch a new one once it expires.
Using a static access token
If you already manage a token elsewhere (or for local testing), skip the OAuth flow entirely by setting:
ADOBE_ACCESS_TOKEN=your-precomputed-access-token ADOBE_COMPANY_ID=your-global-company-id
When ADOBE_ACCESS_TOKEN is set, it is used as-is on every request and ADOBE_CLIENT_ID/ADOBE_CLIENT_SECRET are not required.
Configuration
// config/adobe-analytics.php return [ 'client_id' => env('ADOBE_CLIENT_ID', ''), 'client_secret' => env('ADOBE_CLIENT_SECRET', ''), 'company_id' => env('ADOBE_COMPANY_ID', ''), 'access_token' => env('ADOBE_ACCESS_TOKEN'), 'scope' => env('ADOBE_SCOPE', 'openid,AdobeID,additional_info.projectedProductContext,read_organizations,additional_info.roles'), 'token_safety_margin' => env('ADOBE_TOKEN_SAFETY_MARGIN', 60), ];
Usage
The package is resolved via the AdobeAnalytics facade or by injecting JeffersonGoncalves\AdobeAnalytics\AdobeAnalytics.
Report suites
use JeffersonGoncalves\AdobeAnalytics\Facades\AdobeAnalytics; $reportSuites = AdobeAnalytics::reportSuites();
Dimensions
$dimensions = AdobeAnalytics::dimensions('mysiterunsid');
Metrics
$metrics = AdobeAnalytics::metrics('mysiterunsid');
Segments
// All segments $segments = AdobeAnalytics::segments(); // Segments available to a specific report suite $segments = AdobeAnalytics::segments('mysiterunsid');
Running a report
$report = AdobeAnalytics::runReport( rsid: 'mysiterunsid', startDate: '2026-01-01', endDate: '2026-01-31', metrics: ['metrics/visits', 'metrics/pageviews'], dimension: 'variables/page', // optional );
Error handling
Any non-2xx API response (including OAuth token failures) throws JeffersonGoncalves\AdobeAnalytics\Exceptions\AdobeAnalyticsException, which exposes the decoded error body:
use JeffersonGoncalves\AdobeAnalytics\Exceptions\AdobeAnalyticsException; try { AdobeAnalytics::dimensions('invalid-rsid'); } catch (AdobeAnalyticsException $e) { logger()->error($e->getMessage(), $e->errorBody()); }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
