Package

Panphp Pan

A simple, lightweight, and privacy-focused product analytics php package.

Package

panphp/pan

View on GitHub →

Pan

GitHub Workflow Status (main) Total Downloads Latest Version License


Pan is a lightweight and privacy-focused PHP product analytics library. It’s designed as a very simple package that you can install via composer require and start tracking your pages or components with a simple data-pan attribute.

At the time of writing, Pan tracks only the following events: impressions, hovers, and clicks. It does not collect any personal information, such as IP addresses, user agents, or any data that could be used to identify a user.

Pan

Use cases:

  • you have different tabs within a page with the same URL, and you want to know which one is the most viewed. By adding the data-pan attribute to your tabs, you can track this information.
  • you have different register buttons in your application, and you want to know which one is the most clicked. By adding the data-pan attribute to your buttons, you can track this information.
  • you have different "help" pop-hovers in your application, and you want to know which one is the most hovered. By adding the data-pan attribute to your pop-hovers, you can track this information.
  • and so on...

It works out-of-the-box with your favorite Laravel stack; updating a button color in your "react" won't trigger a new impression, but seeing that same button in a different Inertia page will. Using Livewire? No problem, Pan works seamlessly with it too.

Visualize your analytics is as simple as typing php artisan pan in your terminal. This command will show you a table with the different analytics you've been tracking, and hopefully, you can use this information to improve your application.

Get Started

Requires PHP 8.3+, and Laravel 11.0+.

You may use Composer to require Pan into your PHP project:

composer require panphp/pan

After, you may install Pan into your Laravel project using the following command:

php artisan install:pan

Finally, you may start tracking your pages or components adding the data-pan attribute to your HTML elements:

<div>
-    <button>Tab 1</button>
+    <button data-pan="tab-1">Tab 1</button>
-    <button>Tab 2</button>
+    <button data-pan="tab-2">Tab 2</button>
</div>

Visualize your product analytics

To visualize your product analytics, you may use the pan Artisan command:

php artisan pan

Flush your product analytics

To flush your product analytics, you may use the pan:flush Artisan command:

php artisan pan:flush

How does it work?

Via middleware, Pan injects a simple JavaScript library into your HTML pages. This library listens to events like viewed, clicked, or hovered and sends the data to your Laravel application. Note that this library does not collect any personal information; such as IP addresses, user agents, or any information that could be used to identify a user.

Also on the client-side, these events are collected in a very performant way and batched together to reduce the number of requests to your server.

On the server-side, Pan only stores: the analytic name, and a counter of how many times the different events were triggered. Via the pan Artisan command, you may visualize this data, and hopefully use this information to improve your application.

Considerations

  • By default, Pan only allows 50 or fewer analytics to be stored. This prevents any potential abuse of the system, as the analytics "name" are controlled on the client-side. Open to suggestions on how to improve this.

License

Pan is open-sourced software licensed under the MIT license.

Panphp Pan Related Articles

Pan - A simple, lightweight, and privacy-focused product analytics php package image

Pan - A simple, lightweight, and privacy-focused product analytics php package

Read article
Pan Analytics Viewer image

Pan Analytics Viewer

Read article
Laravel Roundup - November image

Laravel Roundup - November

Read article
Laravel Truss: Live Interactive Database ER Diagrams image

Laravel Truss: Live Interactive Database ER Diagrams

Read article
Five resources for your Friday image

Five resources for your Friday

Read article

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

NativePHP

The fastest way to build fully native apps for any platform (with AI or not)

NativePHP

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift