Skip to content
Frameworks

Laravel analytics with revenue attribution

2 min read · Updated · By the Reveata team

Short answerPaste the Reveata snippet into the Blade layout that renders your pages' head, optionally inside @production. Inertia navigation is tracked automatically, and you pass the visitor id as checkout metadata so each payment is credited to its visit.

Laravel apps that charge customers usually do it with Laravel Cashier (opens in a new tab) on Stripe. That is good news for attribution: Cashier's checkout accepts metadata, and that is all Reveata needs.

What you get

  • Every page tracked, Blade or Inertia. Inertia page changes go through the History API, which the script follows.
  • Production only, if you like. Wrap the snippet in Blade's @production directive so local and staging traffic never reaches your numbers.
  • Stripe payments credited to visits, one-off or subscription, through Cashier's checkout metadata.
  • MRR by channel from your Stripe subscriptions (Stripe subscription analytics).

How to install it

  1. Open the layout your pages use, usually resources/views/layouts/app.blade.php. Starter kits also have layouts/guest.blade.php for sign-in pages; with Inertia, use the root template, usually resources/views/app.blade.php.
  2. Paste the snippet before </head>, inside @production … @endproduction if you want it in production only.
  3. Deploy. If you cache views, run php artisan view:cache again.

Linking payments to visits

Add two hidden fields to the form with your buy button, filled from window.reveata.metadata(). Then pass them as the Checkout Session's metadata:

php
return $request->user()->checkout(['price_123' => 1], [
    'success_url' => route('thanks'),
    'metadata' => array_filter($request->only(['reveata_visitor_id', 'reveata_session_id'])),
]);

For subscriptions, use newSubscription('default', 'price_123')->checkout([...]) with the same metadata; renewals then keep the first payment's source. Connect the same Stripe account in Reveata first (Stripe Checkout attribution).

If you bill another way, post payments to the Payments API with a site key stored in config/services.php.

Serving the script from your own domain

Two routes in routes/web.php can proxy the script and events (the Laravel section of proxy through your own server). Store the secret as REVEATA_PROXY_SECRET and read it through config(), so it survives php artisan config:cache. Forge and most servers run NGINX in front, which can proxy instead (NGINX).

Frequently asked questions

Why do I see no visits from staging?

If the snippet is wrapped in @production, nothing is sent outside production. That is on purpose; test the production site.

Does Cashier need anything special?

No. Cashier passes metadata through to the Stripe Checkout Session, where Reveata reads it.

My guest pages aren't tracked. Why?

Starter kits render them from a separate layout. Add the snippet to every layout that renders <head>.

See it with your own numbersReveata ties every visit and sale to the source that brought it. Add your website in a minute.
Get started
Was this page useful?
IntegrationStripe subscription analytics by acquisition channelWith Stripe connected, Reveata reads your subscriptions and invoices to show MRR and its movements, and groups paying subscriptions by the first-touch channel of each customer, so you can see which channels bring subscribers who stay.IntegrationStripe Checkout analytics and attributionAdd the Reveata visitor and session ids to the metadata of each Stripe Checkout Session your server creates. When Stripe reports the payment, Reveata reads the ids and credits the money to the exact visit that started the checkout.IntegrationNGINX analytics proxy and snippet injectionNGINX can insert the Reveata snippet into every HTML page with sub_filter, and proxy the script and events through two locations on your own domain. With your website's proxy secret, Reveata trusts the visitor's address NGINX forwards, so locations stay accurate.IntegrationAngular analytics with ReveataPaste the Reveata snippet before the closing head tag of src/index.html. ng build keeps it in the built page, server-side rendering included, and the Angular Router's History API navigation is counted automatically. HashLocationStrategy needs data-hash="true".IntegrationAstro analytics with revenue attributionPaste the Reveata snippet with is:inline into the Astro layout that renders the head of every page. Astro then leaves the tag as written, view transitions are tracked, and payment links or checkouts started from your pages are credited to the visit behind them.IntegrationDjango analytics with revenue attributionPaste the Reveata snippet before the closing head tag of the base template your Django templates extend. Every page is tracked, the Django admin is not, and two hidden form fields let your checkout view put the visitor id into the payment's metadata.