ominity / laravel-ominity
Ominity API client wrapper for Laravel
Requires
- php: ^8.1|^8.2
- ext-json: *
- illuminate/support: ^10.0|^11.0
- ominity/ominity-api-php: ^1.4.0
Requires (Dev)
- laravel/pint: ^1.1
- laravel/socialite: ^5.5
- mockery/mockery: ^1.4
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0
Suggests
- laravel/socialite: Use Ominity OAuth to authenticate via Laravel Socialite with the Ominity API. This is needed for some endpoints.
README
Requirements
- An active installation of Ominity.
- Up-to-date OpenSSL (or other SSL/TLS toolkit)
- PHP >= 8.1
- Laravel >= 10.0
Installation
You can install the package via Composer. Run the following command in your terminal:
composer require ominity/laravel-ominity
After installing the package, the Ominity service will be available for use in your Laravel application.
Configuration
Publish the configuration file using the following Artisan command:
php artisan vendor:publish --provider="Ominity\Laravel\OminityServiceProvider"
This will create a config/ominity.php file where you can configure the package settings.
Tracking
The package now includes a first-party visitor/event tracking layer.
Add the existing script directive to your layout:
@ominity_scripts
That now does two things:
- loads
vendor/ominity/ominity.js - boots the tracking runtime with the current visitor ID, authenticated user ID, route endpoint, and page metadata
Tracked automatically in the browser:
- page views
- session starts
- scroll depth milestones
- outbound link clicks
- file downloads
- native form submits
- custom click events via
data-ominity-event
Configuration lives under config/ominity.php in the tracking section.
Important environment flags:
OMINITY_TRACKING_ENABLED=true OMINITY_TRACKING_SEND_IN_LOCAL=false OMINITY_TRACKING_LOG_IN_LOCAL=true
Local environment behavior defaults to logging events instead of forwarding them to Ominity.
For manual page metadata you can use:
@ominity_tracking_meta([ 'origin_resource' => [ 'resource' => 'product', 'id' => $product->id, 'slug' => $product->slug, ], ])
For server-side access:
Ominity::tracking()->track([ 'event' => 'purchase', 'visitorId' => Ominity::tracking()->getVisitorId(), 'metadata' => [ 'order_id' => $order->id, ], ]);
License
The MIT License. Copyright (c) 2024, Ominity (Connexeon BV)