A few days ago, I got rid of Google Analytics on all of my websites, and moved all my analytics needs to a self–hosted instance of Open Web Analytics.
The main reason for doing this is the privacy of the visitors of the websites — while some people are okay with (or do not care/know about) being tracked by Google wherever they go, some might not be, and it is not much effort to run your own analytics server.
OWA is a very well maintained product, and is basically equal to Google Analytics in terms of core functionality. (Page views, Acquisition, Events/Actions, etc.) Open Web Analytics has a full comparison which you can have a look at and see if it has all the functionality you need.
Here is how I did it:
Acquire a server running PHP & MySQL I chose DigitalOcean (referral link) for this, as they offer cheap options which are perfect for the small needs of an analytics server. I set up the 5$/month option, running Ubuntu 14.04 and the LAMP (Linux, Apache, MySQL, PHP) stack.
- Create the database and user for Open Web Analytics
Assuming you went with the LAMP stack and are now using MySQL, this is what you have to do to get your server ready for OWA. First, create a database to store your analytics data.
CREATE DATABASE analytics;
Then create the user OWA is going to use to access the data.
CREATE USER 'openwebanalytics'@'localhost' IDENTIFIED BY 'somepassword';
Now the user exists, but they do not have access to the database. Lets fix that:
GRANT ALL PRIVILEGES ON analytics.* TO 'openwebanalytics'@'localhost';
Now we just need to reload the permission for the new setup to come into effect.
- Download Open Web Analytics
If you do not have it already, install
giton your server by running
apt-get install git
Change into your web servers root folder, which is
/var/www/htmlon my droplet
and download OWA into that folder with git.
git clone [email protected]:padams/Open-Web-Analytics
Make sure the www-data user (which OWA uses) has the right file permissions set up before continuing by running the following commands (replacing /var/www/html with your web servers root folder):
sudo chown -R www-data:www-data /var/www/html sudo chmod -R 755 /var/www/html
Install Open Web Analytics OWA thankfully comes with a very handy installer, so you just have to open
http://yourdomain.com/install.phpin your browser and follow the steps. When asked for the database credentials, the database name is
analytics, the username
openwebanalyticsand the password whatever you set it to.
- Track your website with Open Web Analytics
The only step remaining is dropping the tracking code into your HTML files:
Don’t forget to replace the
owa_baseUrlwith your domain and to set the correct site id!
Congratulations, you are now tracking your website with Open Web Analytics!
This post was originally published on N-O-D-E.net.
Liked this post? Sign up for the weekly newsletter!
Be the first to know when a new article is posted and get an inside scoop on the most interesting news and the freshest links of the week. (I hate spam just as much as you do, so no spam, ever. Promise.)
Tweet this article