Easily Analyse Your Website Traffic From the Linux Terminal With GoAccess

Creating and operating a web site is a enjoyable and difficult pastime—particularly should you host it on a Linux system, utilizing your personal {hardware} or a VPS. But measuring customer visitors and analyzing conduct may be troublesome should you do not need to depend on intrusive third-party analytics packages.


GoAccess gathers knowledge out of your server logs and gives a fantastic terminal person interface the place you may uncover what guests need out of your web site, and the best way to enhance it.


Why Not Use Google Analytics?

A finger arranges letters to spell the word 'Analytics' above a row of coloured pencils

Google Analytics is the de-facto king of analytics packages, and most of the websites you’ll go to right this moment (together with this one) will document fundamental information about your go to, together with your IP deal with, browser, working system, and extra.

Your progress round these websites will probably be tracked utilizing cookies. The benefits of Google Analytics for web site house owners are apparent. It’s simple to begin with, free to make use of, and highly effective.

You can deploy Google Analytics on nearly any webpage by copying a code snippet into the header of your pages, utilizing plugins, or following our instructions to add Google Analytics to your WordPress site.

But Google does not have the greatest fame as a respecter of privateness, and if persons are visiting your web site from different nations, you will have considerations that using Google Analytics will land you in hot water with the varied knowledge safety businesses.

Plus, should you’re operating a web site by yourself {hardware} in your personal dwelling, Google Analytics can simply really feel a bit… icky.

GoAccess Leverages Your Access Logs to Provide Great Analytics

Aside from sharing the identical initialization and related performance as Google’s providing, GoAccess could not be extra totally different in the way it works.

When you run a Linux server, both on a bodily machine or a VPS, it is commonplace follow to log all visits in entry logs. These logs document all the info supplied up by your customer’s browser—sometimes together with system sort, IP deal with, working system, and browser, alongside the web page they’re viewing and the time.

Looking via these logs may give you some perception into who’s visiting your web site, what they’re , and extra. But entry logs aren’t particularly simple to learn, and counting each single entry is time-consuming and tedious.

GoAccess takes the info in your logs and codecs it in a means that is intuitive and simple to learn, with graphs and charts, displaying varied metrics together with guests per day, requested recordsdata, time distribution, static assets, nation of origin, standing codes, and extra.

It’s not privateness invading, does not ship person knowledge out of the nation, and does not require you to include Google’s code.

Install GoAccess on Your Linux Server

GoAccess is out there in the commonplace repositories for many distros. To set up GoAccess on Debian or Ubuntu:

 sudo apt set up goaccess 

On Arch and associated distros:

 pacman -S goaccess 

Or for Fedora:

 yum set up goaccess 

If Gentoo is your distro of alternative:

 emerge net-analyzer/goaccess 

You’ll want to inform GoAccess precisely how your log recordsdata are formatted. Use nano to edit the GoAccess config file:

 sudo /and many others/goaccess/goaccess.conf 

Everything on this file is commented out, and you will want to uncomment traces that correspond with the time format, date format, and log format. You can check one of your system logs to find whether or not they write the date format as %d/%b/%Y or %Y-%m-%d.

Save and exit nano with Ctrl + O then Ctrl + X.

Use GoAccess to View Your Website Analytics in the Terminal

Using GoAccess to view your logs is simple: merely feed the path to your log or logs to GoAccess. Apache logs are often saved in /var/log/apache2/, whereas NGINX logs are in /var/log/nginx/. For occasion, operating:

 goaccess /var/log/apache2/your_site.log 
goaccess output in the terminal

…will produce output much like the above picture.

You can see that the fields displayed embody:

  • Overall Analyzed Requests: This part offers a breakdown of complete requests, distinctive guests, requested recordsdata, referrers, and extra.
  • Unique Visitors Per Day (together with spiders): This part reveals you a bar chart of tourists per day.
  • Requested Files (URLs): Gives a listing of the seven most visited URLs, along with the complete bandwidth for every, the complete variety of hits, and the share of visitors.
  • Static Requests: These are requests for recordsdata that aren’t HTML. Usually CSS or photos.
  • Not Found URLs (404s): Shows the URLs which have been requested, however not discovered. Unless your web site is configured poorly, these are more likely to be bots attempting for generally used targets corresponding to login, settings, or config pages.
  • Visitor Hostnames and IPs: Shows the IP addresses of the seven most frequent guests. If a hostname is out there, it is going to present this, too. These are more likely to belong to RSS feed readers.
  • Operating Systems: This reveals you the commonest working techniques of customers visiting your web site.
  • Browsers: The commonest browsers visiting your web site.
  • Referring Sites: Where guests got here from to get to a selected web page.

Analyzing a single log file is enjoyable, however analyzing a number of recordsdata concurrently offers you a view of your web site’s efficiency over time. Feed in your complete log listing with:

 goaccess /path/to/logs/* 

Or selectively parse a number of log recordsdata with:

 goaccess your-site.log your-site.log.1 your-site.log.2 

View GoAccess Analytics in Your Browser

GoAccess web panel showing browsers and time distribution

While viewing log file analytics in your terminal is the coolest means of doing something, some individuals desire to make use of browsers to view statistics.

GoAccess can generate and replace an HTML file in real-time with:

 goaccess /path/to/log/file.log -o /path/to/report.html  

You can then open report.html in your browser.

If you need to have the ability to entry your GoAccess report via an online deal with, write the report back to the HTML listing of your web site.

If you are not operating GoAccess as the root person, or in case your person does not have write permissions for the HTML listing, use sudo. For occasion:

 goaccess /path/to/log/file.log -o /var/www/your-site-root-directory/report.html --real-time-html 

You can then entry the report from any machine at https://your-site.tld/report.html.

As you’d count on, the report is far prettier than it seems in the terminal, though it accommodates the identical info, and you’ll click on on components. To change from the default theme, click on the cog on the left aspect of the display screen, then choose darkish grey, shiny, darkish blue, and darkish purple.

You can even select the variety of gadgets per web page and the variety of layouts.

GoAccess Isn’t the Only Privacy-Friendly Alternative to Google Analytics

Running GoAccess in your Linux server is straightforward, and implies that you need not depart the consolation of your terminal should you do not need to.

If you wish to view your web site analytics in your browser, Google Analytics is not your solely alternative. There are a number of nice privacy-friendly options to Google Analytics.

https://information.google.com/__i/rss/rd/articles/CBMiVGh0dHBzOi8vd3d3Lm1ha2V1c2VvZi5jb20vYW5hbHlzZS13ZWJzaXRlLXRyYWZmaWMtZnJvbS1saW51eC10ZXJtaW5hbC13aXRoLWdvYWNjZXNzL9IBAA?oc=5

Related Posts