integration-laravel

Integrates PostHog analytics into Laravel apps via the official PHP SDK.

58|5|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/PostHog/skills --skill integration-laravel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: integration-laravel
Source: https://github.com/PostHog/skills/tree/main/skills/posthog/integration/skills/laravel
Command: npx skills add https://github.com/PostHog/skills --skill integration-laravel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Laravel applications often lack integrated analytics and reliable user tracking. This skill enables PostHog analytics by instrumenting events, identifying users, and exposing feature flags with minimal changes to your codebase.

Core Features & Use Cases

  • Instrument server-side analytics using the PHP SDK to capture events like user logins, signups, dashboard views, and error tracking.
  • Identify users on authentication flows and tie events together across sessions using a distinct_id.
  • Utilize feature flags to gate features and customize experiences in Laravel apps.

Quick Start

Install the PostHog PHP SDK, configure POSTHOG_HOST and POSTHOG_PROJECT_TOKEN in the environment, initialize PostHog in the app service provider, and start identifying users and capturing events as shown in the examples.

Frequently Asked Questions about integration-laravel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate PostHog analytics into a Laravel application?

To integrate PostHog analytics into a Laravel application, install the official PHP SDK, configure environment variables for your API key and host, initialize PostHog in the app service provider, and use a PostHogService wrapper to capture events and identify users.

How do I capture server-side events in Laravel using the PHP SDK?

You can capture server-side events in Laravel using the PHP SDK by calling the capture method through a PostHogService wrapper, instrumenting key user actions like logins, signups, and dashboard views tied to a distinct_id.

Can I use PostHog feature flags to gate features in my Laravel app?

Yes, you can use PostHog feature flags to gate features in Laravel by utilizing the isFeatureEnabled and getFeatureFlagPayload calls provided by the PostHogService wrapper to customize user experiences.

Do I need specific environment variables to configure PostHog in Laravel?

Yes, configuring PostHog in Laravel requires setting specific environment variables, specifically POSTHOG_HOST and POSTHOG_PROJECT_TOKEN, to initialize the PHP SDK and enable server-side instrumentation.

How does PostHog identify users across different sessions in Laravel?

PostHog identifies users across sessions in Laravel by using the identify method within your authentication flows, tying captured events together using a unique distinct_id for reliable user tracking.