A few weeks ago, I was about to take over an abandoned analytics plugin. The deal didn’t go through, but I got the chance to look at some of the open issues and bugs raised by users. Most of them were centered around the slowness of the plugin after various periods of time. Others were about slow page speed for their visitors.
Now, all these analytics plugins for WordPress store their data locally, as in the same database as WordPress itself. After a while, depending on the amount of data saved in each row, the database will grow and become sluggish.
I have my own analytics plugin, used internally for all my clients. I have recently started to promote it on various social networks and communities, and also did a bit of work on it to optimize the codebase and its functionality.
Let’s see how Active Analytics works.
Table of Contents
Active Analytics records every user’s page view. That is every page view coming from a real user, and not a bot, a crawler, a spider or a CRON job. The data is saved asynchronously, and it contains the bare minimum.
One thing I miss in the new Google Analytics (GA4) is the main traffic chart. I don’t need much, I need to see the evolution of my website’s traffic (unique users, impressions, sessions) over the past 30 days. And this is what ALL my clients need to see. 99% of website owners, or small business owners, DO NOT NEED the new GA4. I stopped using it a long time ago, and started recording my own data, the way I require it. And I don’t need much.
The amount of data stored for each page view is paramount for a local plugin. Basically, I need to be able to build useful charts using minimal data. What I need is the traffic evolution on a daily basis, and I need to see how many unique users, page views, and sessions I had. I can then build a chart spanning over the past 30 days, 60, 90 or as much as I want (and it fits the screen).
I also need to know where my users came from, what search engines they used, or which website referred them.
No Cookies, No Cry
How do I save sessions without cookies? All browsers nowadays use the
localStorage API, so that’s where I store my data, and I also remove it when it expires (yes, it requires another
localStorage value to save the expiry date). The upside is that it’s fast, and it’s private. Cookies are more susceptible to “sniffing” than
localStorageread-only property of the
windowinterface allows you to access a
Storageobject for the
Document‘s origin; the stored data is saved across browser sessions.
MDN Web Docs
localStorageis similar to
sessionStorage, except that while
localStoragedata has no expiration time,
sessionStoragedata gets cleared when the page session ends — that is, when the page is closed. (
localStoragedata for a document loaded in a “private browsing” or “incognito” session is cleared when the last “private” tab is closed.)
This is another aspect of efficiently storing data.
Do I need analytics older than 3 years? Two? One? Probably not. Lots of things change in 3 years. I pivoted twice, and I changed from a developer blog to a WordPress plugin marketplace, then back to a developer blog, then back to a WordPress plugin marketplace (Envato this time).
If I’m being honest, I only need the last 90 days. If I want historical data, I always have Google Search Console.
I use my own plugin for my own websites. I use it for my clients’ websites.
Active Analytics has become a daily necessity, and the data is available at a glance with the most relevant information anyone would need.
If you like this article, go ahead and follow me on Twitter or buy me a coffee to support my work!