Skip to content
Snippets Groups Projects
matomo.md 2.11 KiB
Newer Older
# Matomo

Matomo is implemented on ecolyo to anonymously track user's navigation and their devices so we understand better how our users use the app.

## Hosting

Matomo is hosted on [statweb.com](https://statweb.grandlyon.com/) where two projects are available :

- PROD for live ecolyo apps

!!! Work in progress
    Prod is not yet enabled in live Ecolyo apps. More development and privacy adjustments are needed.

- REC for every alpha instance

_For our development, every alpha instance points to the REC project. That way, we work in an environment that is close to our production one._

## Local testing 

### Matomo server

Matomo is disabled by default on local development to optimize performances. To develop specific features related to matomo withtout having to deploy to alpha, follow theses instructions.

```bash
cd docker
docker-compose -f docker-compose.matomo.yml up -d
```

Now visit matomo at [localhost://9800/index.php](http://localhost:9800/index.php) and follow the given instructions to setup your matomo.

On step 5, create a super user with the credentials you want, for example

!!! info ""
    ```
    root
    Testtest1
    ```

On step6, enter dummy values and select a time zone.

Once you finish the setup and access the server, you should see a warning telling you that matomo has not been configured with the correct port. To fix this problem follow these instrcutions.
```
docker ps
# copy container id of matomo

docker exec -it [containerID] bash

# Install vi
apt-get update
apt-get install vim

# Edit config.ini.php
vi config/config.ini.php
```

and under "[General]" add the port **9800** to the following line :
```
trusted_hosts[] = "localhost:9800"
```

After reloading, you should be able to login. We need to make one last change for our app to send data to our matomo server.

### Ecoloy app
In the file 
src/targets/browser/**index.tsx** at line 66 comment the dev condition that is preventing the tracker from being initialized.
```jsx
  if (
    window.Piwik
    // && !isDev
  ) {
```

When you navigate inside the Ecolyo app, in the network tab you should see requests to our matomo server 🎉🎉🎉