Jetrack

Jetrack

Installation Guides

Laravel Installation

Install Jetrack in your Laravel application

Jetrack integrates seamlessly with Laravel applications. Add the tracking script to your main layout file to track all pages.

Installation

The best approach is to add the tracking script to your main Blade layout file, which is typically used across all pages.

Step 1: Locate Your Main Layout

In most Laravel applications, the main layout is at:

  • resources/views/layouts/app.blade.php
  • Or resources/views/layouts/master.blade.php

Step 2: Add the Script

Open your layout file and add the tracking script in the <head> section:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>@yield('title', config('app.name'))</title>
    
    <!-- Jetrack -->
    <script
        async
        defer
        data-website-id="your-unique-id"
        src="https://analytics.brandjet.ai/script.js">
    </script>
    
    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
    @yield('content')
</body>
</html>

Using Environment Variables

For better configuration management across environments:

Step 1: Add to .env

BRANDJET_WEBSITE_ID=your-unique-id

Step 2: Update Your Layout

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>@yield('title', config('app.name'))</title>
    
    @if(config('services.brandjet.website_id'))
        <!-- Jetrack -->
        <script
            async
            defer
            data-website-id="{{ config('services.brandjet.website_id') }}"
            src="https://analytics.brandjet.ai/script.js">
        </script>
    @end if
</head>

Step 3: Add Config

Create or update config/services.php:

return [
    // ... other services
    
    'brandjet' => [
        'website_id' => env('BRANDJET_WEBSITE_ID'),
    ],
];

Laravel Livewire Support

Br andJet automatically tracks Livewire page navigations and component interactions. No additional configuration needed!

Laravel Inertia.js

For Inertia.js applications, add the script to your root template:

{{-- resources/views/app.blade.php --}}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    
    <!-- Jetrack -->
    <script
        async
        defer
        data-website-id="your-unique-id"
        src="https://analytics.brandjet.ai/script.js">
    </script>
    
    @vite('resources/js/app.js')
    @inertiaHead
</head>
<body>
    @inertia
</body>
</html>

Route changes are automatically tracked!

Conditional Loading

To load the script only in production:

@production
    <!-- Jetrack -->
    <script
        async
        defer
        data-website-id="{{ config('services.brandjet.website_id') }}"
        src="https://analytics.brandjet.ai/script.js">
    </script>
@endproduction

Testing

  1. Add the tracking script to your layout
  2. Run php artisan serve
  3. Visit http://localhost:8000
  4. Enable localhost debugging in BrandJet settings
  5. Check your dashboard for visitor data

Troubleshooting

Script Not Loading

  • Clear your view cache: php artisan view:clear
  • Verify the script is in your main layout
  • Check browser console for errors

Not Tracking

  • Ensure the layout is being used by your views
  • Verify your website ID is correct
  • Check that the script appears in page source

Next Steps

On this page