Ditch Google Analytics for Plausible Analytics on Amazon Lightsail

Plausible is a simple and privacy-friendly alternative to Google Analytics. It’s a small (94% smaller than Google Analytics), open-source tool that allows users to either self-host or pay for the cloud-hosted version. If you want an easy-to-use tool an…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Brian Graf

Plausible is a simple and privacy-friendly alternative to Google Analytics. It's a small (94% smaller than Google Analytics), open-source tool that allows users to either self-host or pay for the cloud-hosted version. If you want an easy-to-use tool and are concerned about privacy or you don't want Google harvesting your analytics data, this is the tool for you!

How can I start using Plausible Analytics?

You have two options:

  1. Plausible.io - Hosted version, paid monthly or yearly, and fully-managed by Plausible.

Plausible Pricing

  1. Plausible.io - Open-source/self-hosted, free, managed by you.

We will be focusing on how to run the open-source version on Amazon Lightsail

What is Amazon Lightsail?

Amazon Lightsail offers easy-to-use virtual private server (VPS) instances, containers, storage, databases, and more at a cost-effective monthly price. Lightsail makes it easy to choose an Operating system or an application blueprint to deploy and use. We will get Plausible running on Lightsail in less than 5 minutes. Let's get started!

Login to Amazon Lightsail

If you do not already have a Lightsail account, head over to Amazon Lightsail and create one.

Once you login to the service, it will look like this:

Lightsail Console

We are going to create an instance. Click 'Create instance'

Create Instance

Choose the region you want this deployed. Currently you have 14 regions globally where your instances can be deployed. I'm using Virginia (US-EAST-1a).

Click the 'OS Only' button and select the latest version of Ubuntu (for me that is 20.04)

Ubuntu Blueprint

To speed up the deployment and configuration we are going to use a Launch Script, which will install and configure some of the required files before we even log in to the instance.

Click on 'Add Launch Script' and paste the following code:

sudo apt update -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli docker-compose containerd.io -y

sudo mkdir /var/www
cd /var/www
sudo git clone https://github.com/plausible/hosting
cd hosting
sudo git clone https://github.com/TheBrianGraf/AmazonLightsail/
sudo chmod +x ./AmazonLightsail/Plausible-conf-setup.sh

The above code does the following:

  • Updates available packages repository
  • Download's Docker and additional Docker components
  • Download's Plausible setup files
  • Download's a Plausible config file

Launch Script

Choose an Instance Size

Lightsail offers a number of different sized instances to meet the needs of it's users. We'll choose the 4GB/2vCPU instance but you can choose a smaller or larger instance as you require.

Instance Plans

Lastly, we'll give the Instance a name. We'll call ours 'Plausible-Analytics'. Click 'Create instance'

Create Instance

Add a static IP and Open Port 8000

We want our Lightsail Instance to keep the same IP address even if the instance is rebooted in the future. To add a Static IP, Click on the name of your instance.

Instance

Click the 'Networking' tab and click 'Attach static IP'

Instance Networking

Click 'Create Static IP' and give it a name. We'll name ours 'Plausible-Analytics-IP'. Click 'Create'.

Attach Static IP to Instance

We'll go ahead and open TCP Port 8000 so that we can reach our Plausible server once it's configured. Click on your instance name again and go back to the 'Networking' Tab.

Under IPv4 Firewall, click 'Add rule'. Type '8000' in the Port box and click 'Create'

Enable Port 8000

Now we are ready to login to our instance and run the last few commands to get up and running.

Login to the instance

Scroll back up to the top of the page and click the 'Connect' tab, then click 'Connect using SSH' this will open a new window that allows you to run commands in your instance.

Copy and paste (or type in) the following code into the SSH terminal:

# Run the config setup file
sudo /var/www/hosting/AmazonLightsail/Plausible-conf-setup.sh

# Change directories to the Plausible files
cd /var/www/hosting

# Kick off the Docker container
sudo docker-compose up --detach
# Wait about 10-20 seconds after the above command completes then run the final command. If it gives an error. Wait another 10 seconds and try it again.
# 
sudo docker-compose exec plausible_db psql -U postgres -d plausible_db -c "UPDATE users SET email_verified = true;"

Once you've run these commands, you will be able to login to Plausible. Copy the IP address of your instance into your web browser and include port 8000. You should now be able to login with the credentials found in the 'plausible-conf.env' file.

Plausible Login

From here you can begin your journey using Plausible instead of Google Analytics. For more information on how to get started with adding your website, you can continue with your setup HERE.


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Brian Graf


Print Share Comment Cite Upload Translate Updates
APA

Brian Graf | Sciencx (2022-10-18T20:04:49+00:00) Ditch Google Analytics for Plausible Analytics on Amazon Lightsail. Retrieved from https://www.scien.cx/2022/10/18/ditch-google-analytics-for-plausible-analytics-on-amazon-lightsail/

MLA
" » Ditch Google Analytics for Plausible Analytics on Amazon Lightsail." Brian Graf | Sciencx - Tuesday October 18, 2022, https://www.scien.cx/2022/10/18/ditch-google-analytics-for-plausible-analytics-on-amazon-lightsail/
HARVARD
Brian Graf | Sciencx Tuesday October 18, 2022 » Ditch Google Analytics for Plausible Analytics on Amazon Lightsail., viewed ,<https://www.scien.cx/2022/10/18/ditch-google-analytics-for-plausible-analytics-on-amazon-lightsail/>
VANCOUVER
Brian Graf | Sciencx - » Ditch Google Analytics for Plausible Analytics on Amazon Lightsail. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/10/18/ditch-google-analytics-for-plausible-analytics-on-amazon-lightsail/
CHICAGO
" » Ditch Google Analytics for Plausible Analytics on Amazon Lightsail." Brian Graf | Sciencx - Accessed . https://www.scien.cx/2022/10/18/ditch-google-analytics-for-plausible-analytics-on-amazon-lightsail/
IEEE
" » Ditch Google Analytics for Plausible Analytics on Amazon Lightsail." Brian Graf | Sciencx [Online]. Available: https://www.scien.cx/2022/10/18/ditch-google-analytics-for-plausible-analytics-on-amazon-lightsail/. [Accessed: ]
rf:citation
» Ditch Google Analytics for Plausible Analytics on Amazon Lightsail | Brian Graf | Sciencx | https://www.scien.cx/2022/10/18/ditch-google-analytics-for-plausible-analytics-on-amazon-lightsail/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.