# Roll Your Own Google Analytics Alternative with Umami on Windows

## What is Umami?

> Umami is a simple, fast, privacy-focused alternative to Google Analytics. -https://github.com/umami-software/umami

## Installation

1. Log into the Windows device
2. Download the latest Umami release Download
3. Download NodeJS Download
4. Download the latest MySQL .msi installer Download
5. Download Microsoft Visual C++ Download
6. Install Microsoft Visual C++
7. Run the downloaded MySQL installer, accepting the defaults and selecting the Typical installation when prompted
8. When the installation completes, make sure "Run MySQL Configurator" is checked > Click Finish
9. Step through the installer accepting all the defaults
10. Enter and confirm a root password when prompted
11. Launch a Terminal or PowerShell window
12. Run the following commands to login into MySQL
    # change directory to mysql\bin
    cd "C:\Program Files\MySQL\MySQL Server*\bin"
    # connect to the database
    .\mysql -u root -p
13. Authenticate with the root password set during the database configuration
14. Run the following commands to create the database and database user
    CREATE DATABASE umami DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    CREATE USER 'umami_rw'@'localhost' IDENTIFIED BY 'um@m1!';
    GRANT ALL ON umami.* TO 'umami_rw'@localhost;
    FLUSH PRIVILEGES;
    EXIT;
    exit
15. Back in File Explorer, navigate to the Downloads directory
16. Install NodeJS, accepting all defaults
17. Extract the downloaded Umami files
18. Rename the extracted folder Umami
19. Cut the Umami folder to a location it can safely run from, C:\apps\Umami in this example
20. Hold the SHIFT key and right click in the white space > Open PowerShell windows here...
21. Run the following commands in the PowerShell window
    # create .env file
    notepad .\.env
22. Paste the following into the .env file

    DATABASE_URL=mysql://umami_rw:um@m1!@localhost:3306/umami
    HASH_SALT=SomethingSecure

23. Save the changes to .env and close Notepad
24. Continue with the following commands in the PowerShell window
    # make sure .env didn't get a .txt extension
    mv .\.env.txt .\.env
    # install dependencies
    npm install --force
    # build umami
    npm run build
    # run umami
    npm start
25. Open a web browser and navigate to http://DNSorIP:3000
26. Login with the username admin and password umami
27. Navigate to Settings > Profile and click the Change Password button
28. Enter the current password (umami) and enter and confirm the new password > Click save
29. Welcome to Umami

## Run Umami on System Startup (Optional, but recommended)

1. Press CTRL + C to kill the running Umami process in the open PowerShell window
2. Open a text editor and paste the following

   :: Start Umami server
   cd /D "%~dp0"
   start "Umami" /b npm start

3. Save the file as umami.bat in the Umami directory, C:\apps\umami in this example
4. Click on the Start Button > Type task > Launch Task Scheduler
5. Right click the Task Scheduler Library folder in the left pane > Create Basic Task...
6. Set the name to Umami and optionally set a Description > Click Next
7. For the Trigger, select When the computer starts > Click Next
8. For the Action, select Start a program > Click Next
9. Complete the form fields as follows:

   Program/script: "C:\apps\Umami\umami.bat"
   Add arguments:
   Start in:

10. Click Next
11. Check the Open the Properties dialog checkbox > Click Finish
12. In the Properties dialog, click the Change User or Group... button
13. Type System in the Object name field > Click OK
14. Check the Run with highest privileges box
15. Click OK to create the scheduled task
16. Right click the Umami task > Run
17. Refresh the open web browser to verify Umami is now running from the scheduled task

Documentation: https://github.com/umami-software/umami