Trace every paid order to its channel
One Blade directive counts every visit, and the Mira facade reports each paid order after the response.
Package mirafive/sdk-laravel
Set up in 5 steps
Install the package
The service provider and the
Mirafacade are discovered automatically, so there is nothing to register. It needs PHP 8.3 or later and Laravel 11, 12 or 13.Code for step 1 of the Laravel setup: Install the package. composer require mirafive/sdk-laravel
Add the two keys
The secret key of a server source sends events from your app and never reaches a page. The website key of a website source goes into the script tag. Both are under Data → Sources.
Code for step 2 of the Laravel setup: Add the two keys. MIRAFIVE_SECRET_KEY=mf_… MIRAFIVE_WEBSITE_KEY=mf_…
Add the script to your layout
@mirafiveScriptprints the two-line script tag with your website key, and a Vite CSP nonce when one is set. It counts every page and starts without cookies.Code for step 3 of the Laravel setup: Add the script to your layout. <head> @mirafiveScript </head>
Send the paid order
Call the facade where your app marks the order as paid, such as the payment webhook.
trackbuffers, and the package sends after the response, so the page never waits.Code for step 4 of the Laravel setup: Send the paid order. use MiraFive\Laravel\Facades\Mira; Mira::track('order_paid', userId: (string) $order->user_id, properties: [ 'revenue' => 328, 'currency' => 'EUR', ]);
Check the setup
The check command sends a test event that is never stored or billed, and ends with "The key and host work." Then open a page on its real domain and watch Data → Live.
Code for step 5 of the Laravel setup: Check the setup. php artisan mirafive:check
MIRA FIVE is analytics built around the person. In a Laravel app one Composer package covers both sides: a Blade directive for the browser, and a facade that sends paid orders from your server.
What will I see after installing?
The first three questions the dashboard answers, from the default setup:
- Which channels send visitors? Acquisition › Channels splits visits into nine channels, from paid search and email to AI assistants such as ChatGPT. In the sample shop, Direct sent 525 visits, Organic search 438 and Paid search 240 over 30 days.
- Which pages do they land on? Journeys › Pages lists every page with pageviews, entries, bounce rate, exits and time on page. Sort by entries to see your landing pages.
- Which goals do they reach? Goals counts every conversion of the events you send, such as a sign-up or a paid order.
The default script sets no cookies, stores nothing on the device and sends no identifier.
How does a paid order reach its channel?
Through the person who paid. Switch the website source to Full under Data → Sources. Then switch the script to full mode, pass your banner’s answer, and identify signed-in visitors with the same id your server sends:
MIRAFIVE_SCRIPT_MODE=full<head>
@mirafiveScript
@auth
<script>mirafive('identify', @json((string) auth()->id()))</script>
@endauth
</head>In full mode the script sends and stores nothing until the visitor answers, and nothing for visitors who decline. Your banner passes the
answer with mirafive('consent', …): true for statistics only, false, or
{ statistics, experiments, targeting }. The paid order then carries the same user id, and MIRA FIVE
puts it on that person, next to the channel of their first visit.
Create a purchase goal for order_paid, and Acquisition shows buyers and revenue per channel and
campaign. The guide Which channel brings the customers who pay?
reads those numbers.
How do I make a webhook count once?
Payment providers sometimes deliver a webhook twice. Mira::send goes out at once with an idempotency
key and returns a receipt, so a repeat is stored once:
use MiraFive\Laravel\Facades\Mira;
Mira::send([
['name' => 'order_paid', 'userId' => (string) $order->user_id, 'properties' => ['revenue' => 328, 'currency' => 'EUR']],
], idempotencyKey: "order-{$order->id}");Server events and the script have separate modes: MIRAFIVE_MODE for server events (full by default)
and MIRAFIVE_SCRIPT_MODE for the tag (consentless by default). Your site decides the lawful basis for
the user ids it sends.
Can I read feature flags?
Yes. Mira::forUser() reads the signed-in user’s feature flags in your
process, and takes the opt-out from the current request:
use MiraFive\Laravel\Facades\Mira;
$flags = Mira::forUser($request->user())->flags();
if ($flags->enabled('new-checkout')) {
// the new checkout
}@mirafiveFlags renders the same answers into the page, so the browser starts from them and the first
paint shows the right variant. A code A/B test is a flag read the same way. The
Laravel SDK docs cover queues, Octane and testing.
Other setups
The same numbers, whichever way your site is built.