Skip to main content

Add Trfyx to your Laravel project

The recommended approach is to add the tracker to the shared Blade layout so it loads on every page.

Add the tracker to your layout

Open your main layout, commonly resources/views/layouts/app.blade.php, and add the tracker inside <head>:
Replace YOUR_TRFYX_PROJECT_ID with the Website ID from your Trfyx project and yourdomain.com with the domain you want to track. Keep the script URL as https://app.trfyx.com/script.js. Do not copy another project’s Website ID.
The Website ID and domain are public browser-tracking configuration. Never place private API keys or server-side secrets in a Blade template.

Optional: use environment configuration

If staging and production use different Trfyx projects, you can keep each environment’s public tracking values in .env and expose them through Laravel configuration. Add the values to your environment file:
Create or update config/trfyx.php:
Then use those values in your Blade layout while keeping the real tracker URL visible:
Replace the environment placeholders with the values from your Trfyx project. Never put secret API credentials in .env values that are exposed to the browser.

Verify installation

  1. Deploy the Laravel application.
  2. Open the production URL.
  3. Navigate through multiple pages.
  4. Check the Trfyx dashboard for the incoming visit.

Troubleshooting

If tracking is missing, verify the layout is actually used by all pages, inspect the browser network panel for blocked requests, check the Website ID and hostname, and make sure your production deployment contains the latest configuration.
Last modified on October 11, 2026