Automated Website Analytics with GoAccess: A Complete Guide for CloudPanel Users

Automated Website Analytics with GoAccess: A Complete Guide for CloudPanel Users

Understanding Your Website Traffic Without Google Analytics

In today’s privacy-conscious world, many website owners are looking for alternatives to traditional analytics tools. If you’re using CloudPanel to manage your websites, I’ve created a powerful automated script that leverages GoAccess to provide detailed traffic analytics while keeping your visitors’ data private and on your own server.

What is GoAccess and Why Should You Care?

GoAccess is a fast, terminal-based log analyzer that creates beautiful HTML reports from your web server logs. Unlike Google Analytics, GoAccess:

  • Doesn’t require any JavaScript on your website
  • Respects user privacy
  • Has no external dependencies
  • Provides real-time analytics
  • Works with your existing server logs

The Automated Setup Script: Your Analytics Solution

I’ve developed a comprehensive bash script that automates the entire setup process for CloudPanel users. This script handles everything from installation to automated report generation, making it easy to get detailed analytics for all your websites.

Key Features

  1. Automatic Installation: The script handles the complete GoAccess installation process.
  2. Multi-Domain Support: Automatically generates reports for all domains in your CloudPanel setup.
  3. Intelligent Log Rotation: Configures logrotate to manage your log files efficiently.
  4. Automated Updates: Sets up a cron job to update your analytics every 5 minutes.
  5. User-Specific Processing: Maintains proper file permissions and ownership.
  6. Non-Destructive Updates: Safely handles new configurations without overwriting existing ones.

Installation Instructions

  1. Download the script:
wget https://git.hhf.technology/hhf/CloudPanel-GoAccess-Analytics-Automation/raw/branch/main/goaccess-setup.sh
  1. Make it executable:
chmod +x goaccess-setup.sh
  1. Before running it if you want to exclude any folders, please do it as shown in the image file below.

  2. Run the script:

sudo ./goaccess-setup.sh

What Happens Behind the Scenes?

The script performs several key functions:

1. GoAccess Installation

  • Adds the official GoAccess repository
  • Installs the latest version
  • Configures system dependencies

2. Log Management

  • Sets up proper log rotation rules
  • Configures compression and retention policies
  • Maintains separate logs for each domain

3. Report Generation

  • Creates an insights directory for each domain
  • Generates HTML reports from access logs
  • Updates reports automatically every 5 minutes

4. Permission Management

  • Sets appropriate file ownership
  • Configures secure directory permissions
  • Ensures proper access control

Where to Find Your Analytics Reports

After running the script, you can find your analytics reports at:

/home/your-username/htdocs/your-domain/insights/goaccess.html

For example, if your domain is example.com, the report would be at:

/home/your-user/htdocs/example.com/insights/goaccess.html

Benefits for CloudPanel Users

  1. Zero Configuration Required

    • Install and forget - the script handles everything
    • Automatic updates keep your analytics current
  2. Resource Efficient

    • Minimal server impact
    • Efficient log processing
    • Smart log rotation to manage disk space
  3. Privacy-Focused

    • All data stays on your server
    • No third-party tracking
    • GDPR-friendly analytics
  4. Cost-Effective

    • No monthly subscriptions
    • No additional services needed
    • Uses existing server logs
  5. Scalable

    • Works with multiple domains
    • Handles growing traffic volumes
    • Adaptable to new sites

Understanding Your Analytics Reports

The generated reports provide detailed insights into:

  • Real-time visitor statistics
  • Unique visitors and pageviews
  • Popular pages and content
  • Traffic sources and referrers
  • Visitor geolocation
  • Browser and device statistics
  • HTTP status codes and errors

Maintenance and Updates

The script is designed to be maintenance-free:

  • Automatically updates reports
  • Manages log rotation
  • Preserves configurations during updates
  • Self-heals permissions

Troubleshooting Tips

  1. Check the cron job logs:
tail -f /var/log/goaccess_cron.log
  1. Verify log file existence:
ls -la /home/your-user/logs/nginx/access.log
  1. Check report generation:
ls -la /home/your-user/htdocs/your-domain/insights/

Future Enhancements

Consider these potential customizations:

  • Custom report themes
  • Email notifications
  • Traffic anomaly detection
  • Custom reporting periods
  • Integration with monitoring tools

Conclusion

This automated GoAccess setup script provides CloudPanel users with a powerful, privacy-focused analytics solution that’s easy to install and maintain. By leveraging your existing server logs, you get valuable insights into your website traffic without compromising user privacy or adding server overhead.

The best part? It’s completely free and open source. You can start monitoring your website traffic today without any additional costs or complex configurations.

Get Started

Ready to get started with privacy-focused analytics? Download the script and follow the installation instructions above. Within minutes, you’ll have detailed analytics for all your CloudPanel-hosted websites.

2 Likes

Yes I am. Thank you. I will take a snapshot before I begin, just in case :face_with_peeking_eye:

Is there any feedback of successes with the tutorial?

its thoroughly tested on my production version. be rest assured.

1 Like

Not working your link: (BAD GATEWAY)

https://git.hhf.technology/hhf/CloudPanel-GoAccess-Analytics-Automation/raw/branch/main/goaccess-setup.sh

yes, git server is under maintenance. will take care of it once i back from break

1 Like

NOT working url

HTTP request sent, awaiting response… 502 Bad Gateway

Yes , git server is down

1 Like

Hi admin,

can we had a chance to get this script! i will want test this and want to impleted it

Thanks

The git server is down at the moment

i am in the process to move to the new infra. once i am back i will

Would be great to have this working for Traefik json logs. I looked online but it seems tricky. Possibly need a custom log parser.

I already have it running for traefik.

Will the script work for Traefik logs? Will this line work?


                        # Generate GoAccess report
                        goaccess "$log_file" \
                            --log-format=COMBINED \
                            --date-format="%d/%b/%Y" \
                            --time-format="%H:%M:%S" \
                            --double-decode \
                            --anonymize-ip \
                            -a \
                            -o "$insights_dir/goaccess.html

NO, this is an exclusive cloudpanel script

The link is still dead. What version of cloudpanel is that for?

1 Like

all versions. i can start the git if you want

Would be great if you can start it and keep it often for a little bit :slight_smile: I want to look at your other helper scripts as well.
Maybe it’s good to host it in a Github repository or similar, so it stays available to the public?
TIA!

1 Like

done. vm is running. migration has lot of changes if i do.