Laravel Integration
Laravel's Blade templating system combined with environment configuration provides a clean and maintainable way to add tracking scripts across your entire application.
Add tracking script to your Laravel app
Laravel's best practice is to add the tracking script to your main layout template and configure your Program ID through environment variables for better security and flexibility.
- Open your main layout file at
resources/views/layouts/app.blade.php
- Add the tracking script in the
<head>
section - Configure your Program ID in your environment file:
<!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>
<script
async
defer
src="https://affonso.io/js/pixel.min.js"
data-affonso="{{ config('affonso.program_id') }}"
data-cookie_duration="{{ config('affonso.cookie_duration') }}"
></script>
</head>
<body>
<main>@yield('content')</main>
</body>
</html>
Create a configuration file at config/affonso.php
and add your credentials to your .env
file following Laravel's configuration conventions.
Testing
- Start your Laravel server:
php artisan serve
- Visit
localhost:8000?atp=test
- Check browser DevTools → Application → Cookies →
affonso_referral
- Deploy and verify tracking in your Affonso dashboard
Note: Ensure your session configuration allows cross-domain cookies if using subdomains.
Next Steps
Once installed, you can access affiliate referral data and pass it to your payment provider. Connect your payment provider →