L

Laravel Integration

Add theBizness.ai analytics to your Laravel application with elegant Blade templates and environment configuration.

Setup Time

5 minutes

Difficulty

Medium

Performance

Elegant

Choose Your Implementation Method

Blade Layout Method
Add analytics to your main layout template with environment configuration

Step 1: Environment Configuration

Add these variables to your .env file:

# .env
THEBIZNESS_ENABLED=true
THEBIZNESS_WEBSITE_ID=your-website-id
THEBIZNESS_DOMAIN=yourdomain.com

Step 2: Create Config File

Create config/analytics.php:

<?php
// config/analytics.php

return [
    'thebizness' => [
        'enabled' => env('THEBIZNESS_ENABLED', false),
        'website_id' => env('THEBIZNESS_WEBSITE_ID'),
        'domain' => env('THEBIZNESS_DOMAIN'),
        'script_url' => env('THEBIZNESS_SCRIPT_URL', 'https://thebizness.ai/js/script.js'),
    ],
];

Step 3: Update Layout Template

Update your main layout file:

{{-- 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">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Scripts -->
    @vite(['resources/css/app.css', 'resources/js/app.js'])
    
    <!-- theBizness Analytics -->
    @if(config('analytics.thebizness.enabled', false))
        <script 
            async 
            defer 
            data-website-id="{{ config('analytics.thebizness.website_id') }}" 
            data-domain="{{ config('analytics.thebizness.domain', request()->getHost()) }}" 
            src="https://thebizness.ai/js/script.js">
        </script>
    @endif
</head>
<body>
    <div id="app">
        @yield('content')
    </div>
</body>
</html>
Laravel Best Practices
  • • Environment-based configuration
  • • Conditional loading based on settings
  • • Auto-detects domain from request
  • • Easy to disable for development
Verify Installation
Test your Laravel analytics integration

✅ Development Check

  1. 1. Run php artisan serve
  2. 2. Visit your Laravel app
  3. 3. Check browser DevTools Network tab
  4. 4. Look for script.js request

📊 Configuration Check

  1. 1. Run php artisan config:cache
  2. 2. Check config('analytics.thebizness')
  3. 3. Verify environment variables
  4. 4. Test different routes
Laravel-Specific Tips
  • • Use different configurations for different environments
  • • Consider disabling analytics in local development
  • • Cache config in production: php artisan config:cache
  • • Test with both authenticated and guest users

🎉 Laravel Integration Complete!

Your Laravel application is now tracking analytics with elegant configuration. Here's what to explore next:

🛒 E-commerce

Track purchases and customer journeys

🔧 Custom Events

Server-side event tracking with Laravel

📊 API Integration

Use theBizness API with Laravel HTTP client