FauryaFaurya
Installation Guidelines

Laravel

How to add Faurya to your Laravel project.

Add Faurya to your Laravel project

Follow these steps to integrate Faurya analytics into your Laravel application.

1. Add Script to Layout

The recommended way to add scripts to all pages in a Laravel application is by using the main layout file.

  1. Open your project's main layout file, typically located at resources/views/layouts/app.blade.php.
  2. Add the Faurya tracking script to the <head> section:
<!-- resources/views/layouts/app.blade.php -->
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script
      defer
      data-website-id="{{ config('faurya.website_id') }}"
      data-domain="{{ config('faurya.domain') }}"
      src="https://faurya.com/js/script.js"
    ></script>
  </head>
</html>

2. Add Configuration (Optional)

For better configuration management, create a Faurya config file:

  1. Create config/faurya.php:
<?php

return [
    'website_id' => env('FAURYA_WEBSITE_ID', ''),
    'domain' => env('FAURYA_DOMAIN', ''),
];
  1. Add to your .env file:
FAURYA_WEBSITE_ID=your_website_id
FAURYA_DOMAIN=yourdomain.com

3. Server-side Revenue Tracking

Connect your Payment Provider

Go to your website settings in Faurya and connect your Stripe or LemonSqueezy account.

Pass metadata during checkout

Stripe

When creating a checkout session, include the Faurya cookies in the metadata:

<?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_xxx',
        'quantity' => 1,
    ]],
    'mode' => 'payment',
    'success_url' => url('/success'),
    'cancel_url' => url('/cancel'),
    'metadata' => [
        'faurya_visitor_id' => request()->cookie('faurya_visitor_id'),
    ],
]);

return redirect($session->url);

LemonSqueezy

For LemonSqueezy, include the Faurya cookies in the custom data:

<?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_price' => 4900,
    'checkout_data' => [
        'custom' => [
            'faurya_visitor_id' => request()->cookie('faurya_visitor_id'),
        ],
    ],
]);

return redirect($response->json()['data']['attributes']['url']);

4. Verify installation

After implementing:

  • Visit your live website
  • Check your Faurya dashboard for incoming data
  • It might take a few minutes for the first pageviews to appear
  • Once a purchase is made, verify that revenue is being attributed correctly

For advanced configuration options like localhost tracking, custom API endpoints, or cross-domain setup, see the script configuration reference.

On this page