Please note: This package is still a work in progress and the Fathom API is also only in early access. Do not use this package in your production environment (yet).
Laravel Fathom
This is a Laravel wrapper for the Fathom Analytics API.
Installation
coming soon...
Usage
Get Account
use MarcReichel\LaravelFathom\Fathom;
Fathom::account()->get();
List Sites
use MarcReichel\LaravelFathom\Fathom;
Fathom::sites()->get();
Limit the results
use MarcReichel\LaravelFathom\Fathom;
Fathom::sites()->limit(5)->get();
Pagination
use MarcReichel\LaravelFathom\Fathom;
Fathom::sites()->after('CDBUGS')->get();
Fathom::sites()->before('CDBUGS')->get();
Get Site
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')->get();
Create Site
use MarcReichel\LaravelFathom\Fathom;
Fathom::sites()->create([
'name' => 'Acme Inc', // required
'sharing' => 'private', // optional, one of 'none', 'private' or 'public'
'share_password' => 'the-jean-genie', // optional
]);
Update Site
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')->update([
'name' => 'Acme Holdings Inc',
'sharing' => 'private',
'share_password' => 'the-jean-genie',
]);
Wipe Site
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')->wipe();
Delete Site
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')->delete();
List Events
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')->events()->get();
Limit the results
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')->events()->limit(5)->get();
Pagination
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->events()
->after('signed-up-to-newsletter')
->get();
Fathom::site('CDBUGS')
->events()
->before('signed-up-to-newsletter')
->get();
Get Event
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->event('signed-up-to-newsletter')
->get();
Create Event
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->events()
->create([
'name' => 'Purchase early access',
]);
Update Event
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->event('purchase-early-access')
->update([
'name' => 'Purchase Early Access (live)',
]);
Wipe event
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->event('purchase-early-access')
->wipe();
Delete event
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->event('purchase-early-access')
->delete();
Aggregation
Pageviews
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->aggregate(['visits'])
->groupByDay()
->groupByField('referrer_hostname')
->orderBy('visits', 'desc')
->timezone('Europe/Berlin')
->limit(200)
->where('pathname', 'is', '/pricing')
->where('pathname', 'is not', '/login')
->get();
Event
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->event('signed-up-for-newsletter')
->aggregate(['visits'])
->groupByDay()
->groupByField('referrer_hostname')
->orderBy('visits', 'desc')
->timezone('Europe/Berlin')
->limit(200)
->where('pathname', 'is', '/pricing')
->where('pathname', 'is not', '/login')
->get();
Current visitors
use MarcReichel\LaravelFathom\Fathom;
Fathom::site('CDBUGS')
->currentVisitors();
Testing
Run the tests with:
composer test
Roadmap
- Improve documentation
Contribution
Pull requests are welcome :)