YouTubevideo· Oct 16, 2024· 10:31· 5,600 views on YouTube
React at a moment you like. The best moments light up here.
if I was to say the word analytics there's probably a few things that come to your head either one it's not privacy Centric so you're thinking yucky Google analytics two it's maybe too bloated maybe not something that you fully need for your given project or three is just maybe too expensive for you right now at least uh your given project isn't making any money so you just want something lightweight something easy something cheap Something Free something open- source so this is pan a lightweight and privacy focused PHP product analytics Li
liary and it's built by a Nuno Maduro larel team member creator of pest and pint and so many others uh that I'm probably just blanking on what all Nuno has created huge contributions to the Lille Community but pan is really
interesting because one it's not and I should say it's also created by David Hill as well on the LEL team lead designer I should say that pan I don't think is trying to fit into the spot of replacing something like a f fathom analytics uh which is an incredible Analytics tool or something like Persia which is something that I use for most of my projects as well because both fom analytics and pers kind of fit into the
hey we're tracking Pages we're tracking views we're tracking Impressions we're tracking how many people are actually U you know landing on that specific page I see pan fitting in more in the lightweight category of things like okay maybe I need to know how many times are people actually click that button that I think that they're clicking or the or
how many times are they actually you know changing specific tabs on this given page now most of the time these full analytics Solutions are going to have something to solve that when it comes to events saying okay when I click this button I want to send this PHP event and register that this button has been clicked and that might work great for you but sometimes I like stuff like that ready to go for me in a new project
without having to dive full into a analytics solution and I think that's where pan fits in perfectly the only thing you need to do is add this simple data- pan attribute so it injects uh some custom JavaScript when you install and then it just works within inertia within Livewire whatever your front end looks like you just have this data pan attribute and then you can do whatever with that that you want currently it looks like a tracks covers attracts um impressions as as well as clicks so if I
had a button that had a data pan attribute of high there I would see when running PHP Artisan pan and again the dashboard view metric system however you like it's all tracked within database migration so it is a database table that you run when installing pan but then the analytics are tracked within this PHP Artisan pan CLI command so why don't we install this and see what this looks like actually being in a project I
actually already updated my opinion starter kit fion to include pans so why don't we go ahead and install a new project in my code folder and we'll get pan up and running to see what it does and what you might want to use pan for in your larel or PHP projects so since
I'm using my starter kit and I'm using the CLI command from GitHub to be able to clone that repo it's going to be the get GH repo clone vision and then my panid directory I will call it that okay so let's go into that and I have this install script that will install everything you'll see here that we're installing the pan migrations as well
after you install pan PHP SL pan so composer require pan PHP pan you can publish the migrations by using the pan install C command and we'll do just that and this is the name of our project everything looks good to go I have a new up and running composer run Dev that the larl team just released a few days ago composer runev to get everything up and
running perfect why don't we go ahead and look in our code Editor to see what all of this looks like okay so pan is composite require pan PHP pan so this is version 0.1 brand new as of recording this video
and but I think it's going to be something that I personally will use on a lot of projects especially just ones I'm getting up and running or I'd like to see how many people are actually using the demo applications that I build for videos and this would be perfect for that okay how many people are clicking this button on this particular page and it gives me a little bit of insight as to if those are incredibly useful to put in the description of videos or to have available publicly again this is not
meant to replace at least in my mind it's not meant to replace a fullblown analytics software solution this is kind of in addition to that and your event driven lightweight version or if you're just starting out a new project that's what I'm going to use it a lot for as well so if I go into the
playground component this is where I already have something just to set up as a data pan playground button so why don't we take a look let's register a new user and then get that started I'm actually just going to migrate a new user just for Simplicity sake so PHP Artisan DB seed and we've got a user in the data base now so we should be able to log in with test example.com and a
password of password and we are in the playground see this High everyone button I'm not going to click on it yet I hovered it I didn't click it so what happens when we run the PHP Artisan pan command we have a playground playground button one impression one hover now you might be
thinking okay yes the biggest thing is for probably buttons or any kind of dropdowns any UI components that you would like this more of the product analytics of how many people are actually using the features that you're building your applications it probably could work on pages for example if you just have a div on a page and you want to get the number of Impressions that people have viewed that page but I don't
think that's where it shines It Shines on those small little features for example in a profile if I wanted to see how many times people actually updated their p password I mean you could probably do that within the database table itself but let's just go ahead and see what that would look like so if we were to go into uh the profile I believe
yeah profile index and let's just go ahead and update password down here and it's as simple as maybe in this flux button uh we'll say uh data pan equals update password button so now going back to our browser if we were to click on
the profile maybe we filled some things out but we didn't actually update the password we will now see that up reflected in the PHP Artisan pan we have four Impressions on it uh with one hover and zero clicks if I was to go ahead and click on this as well as go back to the
playground and click on that then we should see that reflected so this is a great way to get some of those lightweight analytics into your application now I think I think one of the interesting things about this package is not just how lightweight it can be and how simple it can be to just slap an attribute onto a button or a tab or a popover or whatever have you that you would like to track and have analytics on but it also does it performant so if we see uh down here it
uh via middle Weare pan injects the simple JavaScript library into your HTML pages and this Library listens to events like viewed clicked or hovered but the cool thing is on the client side these events are collected in a performant way and batched together to reduce the number of requests to your server so one thing to note that pan only allows 50 or fewer analytics to be stored and that's specific to the data- pan option you can only have 50 unique ones of those I am curious really quick if I was to have I don't know why he would do this but if I was to have two buttons they were both
playground buttons can I do that let's see forgot to restart the server go to the playground so both of these should now have Impressions um if I was go back PHP R in pan so we're sitting at seven Impressions five hovers so if I was to click on one run it again three three clicks there four so I might not be counting them all as one maybe it only
defaults to like the last one on the page I don't know the specifics behind that I'll have to look into that but there's a reason why I already put this into my opinion and starter kit because I like having some of those things out of the box without having to think too much of what the actual install process
and who I'm pushing it to and which account is being registered to and viewing those requests because usually in a full analytic software you probably have a different account or domain that you have to set up for a new project that you're doing now this is all just stored on your server within your database so why don't we take a look at what those migrations look like so if we take look at pan migrations we have this create pan analytics table which just has simple uh Impressions hovers and
clicks and I've seen a couple people do this but you would be able to just grab the information here if you wanted to display it in a dashboard a Nova component fil filament component um if you were using a MySQL table or postr table and you want to put it into a pulse component that is doable so yeah
give this simple lightweight and privacy Focus product analytics PHP package pan a star check it out especially if you're looking for something lightweight something to use maybe in start of projects or just to have events that you're not maybe it's not as necessary
to push those to a specific dashboard and you just want as the engineer maybe not even for product specific stuff you just want a little bit more insight as to are the users actually doing the thing that you want them to do so check it out keep building keep keep creating