Download the PHP package mbuzz/mbuzz-php without Composer
On this page you can find all versions of the php package mbuzz/mbuzz-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mbuzz/mbuzz-php
More information about mbuzz/mbuzz-php
Files in mbuzz/mbuzz-php
Package mbuzz-php
Short Description Multi-touch attribution SDK for PHP - framework agnostic
License MIT
Homepage https://mbuzz.co
Informations about the package mbuzz-php
Mbuzz PHP SDK
Multi-touch attribution SDK for PHP. Framework-agnostic core with first-party adapters for Laravel, Symfony, and any PSR-15 framework (Slim, Mezzio, …).
Requirements
- PHP 8.1+
- ext-curl
- ext-json
Installation
Quick Start
Configuration Options
By default the API URL is https://api.mbuzz.co/api/v1 — all traffic routes
through the edge ingest proxy.
Data-resident installs (api_url)
An account whose data must stay in a region (for example Australia) is given a
region API key (sk_live_au_...) and a host to send to. Set both:
api_url is an explicit opt-in with three rules, so a normal install can never
be redirected by accident:
- It must be
https://. Anything else throwsInvalidArgumentException. - A region key requires
api_url, andapi_urlrequires a region key. A mismatch throws atinit()instead of sending visitor details to the wrong host. - There is no fallback host. A request that fails is dropped, never retried
against
api.mbuzz.co.
Non-blocking dispatch
Fire-and-forget tracking calls (Mbuzz::initFromRequest() session creates,
explicit Api::post) are queued and flushed in the PHP shutdown phase. On
FPM and LiteSpeed the SDK calls fastcgi_finish_request /
litespeed_finish_request first, so the user receives the response before
the tracking POST goes out — page-render latency is unaffected even when
the API is slow. On environments without FPM (CLI workers, plain CGI) the
queue still flushes in shutdown but synchronously; the session POST keeps a
tight 2-second cap as a backstop.
Mbuzz::event(), Mbuzz::conversion(), and Mbuzz::identify() remain
synchronous because callers want the response (event_id, conversion_id,
attribution).
Full-page caching — REQUIRED on every install
Add this inline in your <head>, on every page. Without it the SDK establishes no visitor and
tracks nothing.
Why
A full-page cache — Cloudflare, Varnish, WP Rocket, Nginx proxy_cache — serves HTML without ever
invoking PHP. On a cache HIT the SDK does not run, so it cannot set the visitor cookie while
rendering the page. Every later event and conversion is then rejected for having nobody to attribute
it to: silently, with no HTTP call and nothing logged, while the page renders perfectly.
POST /_mbuzz/session is the one request that always reaches the app, because no cache stores a
POST. The snippet above triggers it; the server mints the cookie on the response, so the id stays
HttpOnly and keeps its full two-year life. (A document.cookie fallback would be capped at 7 days
by Safari's ITP — 24 hours after an ad click — which is worse than the bug.)
Inline, not an enqueued file. Asset optimisers delay external scripts until the visitor first interacts, so an external trigger never runs for the visitor who lands and converts without clicking — exactly the traffic this recovers.
The endpoint is handled by the SDK. The bundled adapters intercept it for you; a hand-rolled plain PHP integration needs the early return shown below.
If you are behind a CDN or WAF
Two layers can sit between the browser and PHP, and both fail silently:
- A JS optimiser decides whether the trigger ever runs. Exclude it from delay/defer/minify.
- A bot or WAF layer decides whether the POST reaches PHP. If
/_mbuzz/sessionis answered with a challenge page rather than a204, allow-list it.
Check both by fetching a page and confirming the script is present unmodified, then confirming
POST /_mbuzz/session returns 204 with a Set-Cookie: _mbuzz_vid header.
Framework Integration
Plain PHP
Laravel
The middleware is duck-typed against Laravel's handle($request, Closure $next)
contract and never imports an Illuminate class. A dedicated service provider /
config publisher is not shipped yet — wire Mbuzz::init() into a provider you
already own.
Symfony
The SymfonySubscriber automatically initializes tracking on each request by listening to the kernel.request event with high priority.
Slim / PSR-15 Frameworks
Add psr/http-server-middleware to your project (Slim and Mezzio already
require it transitively):
Then wire it in:
The same middleware works for Mezzio, Hyperf, and any other PSR-15 compliant framework.
WordPress
A dedicated WordPress plugin (with WooCommerce conversion hooks) is on the
roadmap — see lib/specs/wordpress-plugin.md.
Until it ships, drop the SDK into a small mu-plugin that calls
Mbuzz::init() on plugins_loaded and Mbuzz::initFromRequest() on
template_redirect.
API Reference
Mbuzz::init(array $options)
Initialize the SDK. Must be called before any tracking methods.
Mbuzz::initFromRequest(): bool
Initialize context from the current HTTP request. Reads the visitor cookie, captures IP and user
agent for server-side session resolution, and handles POST /_mbuzz/session.
Returns true when the request WAS the session endpoint and has already been answered — the
cookie is set and a 204 is on its way. The caller must return immediately rather than render:
The bundled Laravel, Symfony and PSR-15 adapters do this for you.
Changed in 2.0.0: previously returned void.
Mbuzz::event(string $eventType, array $properties = [])
Track an event. Returns result array with event_id on success, false on failure.
Mbuzz::conversion(string $conversionType, array $options = [])
Track a conversion. Options:
revenue(float): Conversion valueuser_id(string): User IDis_acquisition(bool): Mark as acquisition conversioninherit_acquisition(bool): Inherit attribution from acquisitionproperties(array): Custom properties
Returns result array with conversion_id on success, false on failure.
Mbuzz::identify(string|int $userId, array $traits = [])
Link the current visitor to a known user. Returns true on success.
Mbuzz::visitorId(), Mbuzz::userId()
Get current tracking IDs.
Mbuzz::reset()
Reset SDK state. Useful for testing or long-running processes.
Cookie Behavior
The SDK sets one cookie:
_mbuzz_vid: Visitor ID (2-year expiry)
The cookie is:
- HttpOnly (not accessible via JavaScript)
- SameSite=Lax
- Secure (on HTTPS connections)
Session resolution is handled server-side using IP and user agent for device fingerprinting.
The cookie is minted only by POST /_mbuzz/session, never by a page response. A page can be
stored by a full-page cache and replayed to every visitor, so a Set-Cookie in it would hand
everyone the same id and merge unrelated people into one journey — corruption rather than loss. A
page response reads the cookie the browser already holds and nothing else.
Development
License
MIT
All versions of mbuzz-php with dependencies
ext-curl Version *
ext-json Version *