Good morning everyone and happy MonDEV! ☕
Did you have a good weekend? Here the mood was set on day trips to the mountains, because taking your head off the monitor is a good thing, especially on the weekend! ?️
But as always, this is not an obstacle to bring you the tool of the week and start off great with some new discoveries.
This week we go back to see a very simple but very interesting tool for Laravel and go back, without much surprise by now, among Nuno Maduro's repos.
This week it's time for Pan PHP a still early-stage analytics tool but very interesting especially for its simplicity and ease of implementation.
This library, through a middleware, injects a JS library into your pages and allows you to observe (on the elements you choose) how many times they have been viewed/hovered over/clicked. The data is collected anonymously and sent in a grouped way to the server (to limit the requests sent), where they will be saved in a dedicated table.
The implementation requires very few steps:
Install the library with:
composer require panphp/pan
Then with artisan install pan:
php artisan install:pan
You will be asked to run the migration for the creation of the table: confirm and you will be ready to use it in your blade/html. How?
Simply by adding the attribute data-pan to the elements you want to monitor. For example, if you have a CTA and want to know how many users have viewed/clicked the button, this is a simple and fast way to do so.
For a quick view of the collected data you can use the command
php artisan pan
Then having the table pan_analytics available in the database you can manage this data in the way that you consider most appropriate ?
I would say that even this week we have loaded up on tools and readings! I hope you found something interesting, as always, any feedback is welcome!
Have a great start of the week!
Happy Coding! 0_1
The above is the detailed content of PHP, Analytics and surroundings. For more information, please follow other related articles on the PHP Chinese website!