Integration Guides

Laravel

Add Rybbit analytics to your Laravel app

Laravel renders pages through Blade layouts, so the snippet goes into the layout file that wraps your site. Read the site ID from config/services.php and .env so it stays out of the template and differs per environment.

Get your tracking snippet

In your Rybbit dashboard, open Site Settings → Tracking Script and copy your snippet. It looks like this:

<script src="https://app.rybbit.io/api/script.js?siteId=YOUR_SITE_ID" defer></script>

YOUR_SITE_ID is the numeric ID of your site. If you self-host Rybbit, app.rybbit.io is the domain of your own instance.

Add the snippet to Laravel

Configure the site ID

Add the Rybbit values to .env:

RYBBIT_INSTANCE_URL=https://app.rybbit.io
RYBBIT_SITE_ID=YOUR_SITE_ID

Then register them in config/services.php:

<?php

return [
    // ... other services

    'rybbit' => [
        'instance_url' => env('RYBBIT_INSTANCE_URL', 'https://app.rybbit.io'),
        'site_id' => env('RYBBIT_SITE_ID'),
    ],
];

Run php artisan config:clear if your configuration is cached, otherwise the new keys are not picked up.

Add the tag to your layout

Open the Blade layout that wraps your pages. In a default install this is resources/views/layouts/app.blade.php; Breeze and Jetstream also ship resources/views/layouts/guest.blade.php, and Inertia apps use resources/views/app.blade.php. Add the tag inside <head>:

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ config('app.name', 'Laravel') }}</title>
    @vite(['resources/css/app.css', 'resources/js/app.js'])

    @production
        <script src="{{ config('services.rybbit.instance_url') }}/api/script.js?siteId={{ config('services.rybbit.site_id') }}" defer></script>
    @endproduction
</head>

@production only renders the tag when APP_ENV=production, so local development is not tracked. Drop the directive if you also want data from staging.

If you have several layouts (for example app and guest), add the tag to each one, or move it into a partial such as resources/views/partials/rybbit.blade.php and @include it from every layout.

Verify installation

Open your live site in a new tab and click through a few pages. Within a few seconds the pageviews appear in the Rybbit dashboard.

If nothing shows up:

  • View the page source and search for script.js?siteId= to confirm the snippet is on the page.
  • Open the browser Network tab and check that script.js returns 200 and that POST requests go to /api/track.
  • Disable ad blockers, or set up a proxy so the script loads from your own domain.
  • See the script troubleshooting guide for other common causes.

Troubleshooting

  • Tag missing in production: run php artisan config:clear and php artisan view:clear after changing .env or config/services.php; cached config and compiled views keep the old values.
  • Tag missing locally: @production hides it unless APP_ENV=production. Set that temporarily to test, or remove the directive.
  • Self-hosted instance: set RYBBIT_INSTANCE_URL to your own domain without a trailing slash; the template appends the script path to it.

Next steps

On this page