Support/Installation Guides
Installation Guides

Set up Flowsery Analytics in a Laravel project

This guide covers adding Flowsery Analytics tracking to your Laravel application.

1. Embed the script in your layout

The cleanest approach is to place the snippet in your main Blade layout.

  1. Open your layout file -- typically resources/views/layouts/app.blade.php.
  2. Insert the Flowsery Analytics snippet inside <head>:
HTML
<!DOCTYPE html>
<html>
  <head>
    <!-- ... other head elements ... -->
    <script
      defer
      data-fl-website-id="{{ config('flowsery.website_id') }}"
      src="https://cdn.flowsery.com/main.js"
    ></script>
  </head>
  <body>
    @yield('content')
  </body>
</html>

2. Add configuration (optional)

For centralised config management, create a dedicated config file:

  1. Create config/flowsery.php:
HTML
<?php return [ 'website_id' =>
env('FLOWSERY_WEBSITE_ID'), ];
  1. Add the value to your .env file:
HTML
FLOWSERY_WEBSITE_ID=flid_******

3. Server-side revenue tracking

Connect your payment provider

Open your website settings in Flowsery Analytics and link your Stripe or LemonSqueezy account.

Pass metadata during checkout

Stripe

When you create a checkout session, forward the Flowsery Analytics cookies in the metadata:

HTML
<?php
 
use Stripe\Stripe;
use Stripe\Checkout\Session;
 
Stripe::setApiKey(config('services.stripe.secret'));
 
$session = Session::create([
    'payment_method_types' =>
['card'], 'line_items' => [[ 'price' => 'price_1234567890', 'quantity' => 1, ]], 'mode' => 'payment', 'success_url' => route('checkout.success'),
'cancel_url' => route('checkout.cancel'), 'metadata' => [ '_fs_vid' => request()->cookie('_fs_vid'), '_fs_sid' => request()->cookie('_fs_sid') ] ]);
return redirect($session->url); ```bash #### LemonSqueezy For LemonSqueezy, include the Flowsery Analytics cookies in the custom data payload: ```html
<?php use Illuminate\Support\Facades\Http; $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . config('services.lemonsqueezy.api_key'),
'Content-Type' => 'application/json' ])->post('https://api.lemonsqueezy.com/v1/checkouts', [ 'store_id' => config('services.lemonsqueezy.store_id'),
'variant_id' => 'your_variant_id', 'custom' => [ '_fs_vid' => request()->cookie('_fs_vid'), '_fs_sid' => request()->cookie('_fs_sid') ] ]); return
redirect($response->json()['data']['attributes']['url']);

4. Confirm everything is working

After deploying:

  • Navigate to your live site
  • Open your Flowsery Analytics dashboard and check for incoming pageviews
  • Allow a couple of minutes for the first data to appear
  • Complete a test purchase and verify that revenue attribution is working

For additional options such as localhost tracking, custom API endpoints, or cross-domain configuration, refer to the script configuration reference.