# What is Metrical

Metrical is a **privacy-first** website analytics tool.

We created Metrical just because we wanted a better (and more private) way to track visits without exposing our visitors' and users' privacy or selling their data.

## What makes Metrical great?

#### 1. Simple UI and only meaningful data

I (Francesco, the creator of Metrical) worked as a developer on a web agency for 7 years. Every time I shared the google analytics data with the clients I needed to spend some hours explaining what the data meant and how to search the data in all the different pages and sections. Metrical is designed on this experience to be as straight-forward as possible, with simple explanations on what the metrics means and only 4-5 different values for page.&#x20;

#### 2. We are consumers too!

We created Metrical to be used on our sites and adapted it based on our needs both as visitors of websites and as data analysts, so we know what a user want from some web analytics and how to show it in the most useful way.&#x20;

#### 3. Privacy-first, always

Lots of web analytics use shady methods to track their users and then sells their data to third parties. We want to create a tool that respects the user privacy (both our users and all the visitors that will be tracked by Metrical) and at the same time can't be used to sell personal data to third parties, because **we don't store any personal data of our visitors**.&#x20;

## Is Metrical free?

**No, Metrical is not free**. We have lots of costs to keep the server running and that's because we ask for a subscription to start using it. In this way, we don't need other ways (read: sell your data, or ask for money to VC) to cover the costs.

Interested? [Register now](https://app.metrical.xyz/register).


# Filter IPS

Sometime you want to log your own visits, especially when your blog or website is still small and your navigation can really influence the stats present in Metrical.

For this reason, you can filter IPS inside an application: just go to the application settings and you can add a list of IPs. Metrical won't save visits from these IPs.

If you want, you can also use a wildcard to filter IPs. Example: if you put only '1.2.' instead of a complete IP, Metrical will filter out all IPs that starts with that address (1.2.3.4, 1.2.122.23, 1.2.1.9, ecc)

This comparison between the visitor IP and the list of IPs inside your application is done as the first thing during a visit, so **no data** will be saved of that visit if the IP matches. &#x20;


# Changelog

## 1.0.0 - 2020-07-10

* Metrical is now available to everyone.
* Add filtered IPs wildcards (Example: '1.2.' => will filter all IPs like 1.2.X.X.)

## 0.1.0 - 2020-02-03

### Changed

* Metrical is now in Beta 🍾
* Open Metrical to beta users.

## 0.0.1 - 2019-04-19

### Added

* First working version of Metrical :)&#x20;


# First setup

First, add a new website from [our website](https://app.metrical.xyz/new). After that, you will receive a UUID code that identifies your website's visits on Metrical.

Then, open your HTML file and include these two lines at the end of your `<body>`

```javascript
<script>
  window.metrical = {
    "app": "Your website UUID"
  }
</script>        
<script async
    src="https://cdn.metrical.xyz/script.js"
    type="text/javascript">
</script>
```

## How about Single Page Apps?

✨Our script is ready to use also for Single Page Apps (React, Angular, Ember, Vue...)! Just include the script at the end of the `<body>` and every changes to the history object will be tracked.


# How to track events

You can add Events to custom actions done by your users on your website. \
&#x20;

Every time a user does an action, **Metrical** tracks that Event and displays it on the events tab of your Website dashboard. \
&#x20;\
Here are some examples of Events that you can track:&#x20;

* When a user clicks on a specific button;
* When a user completes a payment;
* When a user downloads something (a pdf, an e-book, etc...).

### How to track an event

It's really easy: just call inside your page (assuming you have already added the [Metrical script](https://docs.metrical.xyz/developers/how-to-start-tracking-users))

```javascript
window.metrical.trackEvent("type_of_event")
```

With the type of event that you added when you created the event on **Metrical**.

Every event will be associated with the nearest visit of that user, so that you can filter events by any visit field.

For example, if you filter only the visits that have as referrer producthunt.com and you go to the **Events** tab, you will also see only the events that are connected to one of those visit.&#x20;


# Custom Domain

Sometimes Ad-blockers will block our `metrical.xyz` domain in order to try to give their users a better privacy and navigation. As we said it before, we don't store any personal information about visitors of your site,  but we offer a solution about this problem: you can setup a subdomain of your main domain to serve the metrical script and calls.&#x20;

With this solution, Ad-blockers won't block our script and calls and you will be able to use Metrical as normal.&#x20;

### How to add a custom domain to Metrical&#x20;

Open your domain provider (Godaddy, Namecheap, ect) and add a subdomain of your choice with a  `CNAME` record pointing to `cdn.metrical.xyz.` (add also the last dot `.`)

Something like this:

`CNAME`       **log.customdomain.com**       `cdn.metrical.xyz.`

Then, add the exact subdomain (without https\:// or http\://) to the settings page of an application on Metrical. This is necessary to obtain a SSL certificate with [Let’s Encrypt](https://letsencrypt.org/), so your data (and the visits of your users will be safe and protected by HTTPS.

### How to change the tracking script to use a custom domain&#x20;

Change cdn.metrical.xyz to your custom domain inside the tracking script, and also add the `host` property inside the `metrical` object.

Like this:

```javascript
<script>
  window.metrical = {
    "app": "Your website UUID",
    "host": "https://log.customdomain.com"
  }
</script>        
<script async
    src="https://log.customdomain.com/script.js"
    type="text/javascript">
</script>
```

After that, you are ready to go!


# Privacy Policy

This is the privacy policy for Metrical (<https://metrical.xyz>) and all the other subdomains and websites that we own and operate.

We want to keep it simple and we don't want to hide behind long paragraphs of text, small lines or difficult words.&#x20;

### We care about you and your data.

We created Metrical just because we wanted a better (and more private) way to track visits without exposing our visitors' and users' privacy or selling their data.

We only ask for data that we will try need and use to give you a great service. If for any reason we will start collect some information that we (or the law) think it's personal, we will let you know.

Also, we don't share or sell any personal information of you or your visitors to third-party, except when required by law. We'll also protect these data to prevent loss, use, modification or theft from people or companies that doesn't work with us.

### What we collect

We already have [a list of all the (few) things](https://docs.metrical.xyz/what-we-track) that we track and save on our servers of the visitors of Metrical and of your websites.

Here is a list of things that we save of our users. We will update this list as soon as we will need some other personal data. (Last update: 03 February 2020).

* **Email address**: this is the only way to identify our users. We will use the email address to send daily or weekly recaps of your websites and also to send updates about the user's subscription or some big updates about Metrical (planned downtimes, changes of this privacy policy...).&#x20;

  We won't send you any newsletter. &#x20;
* **Name**: we need your name to personalize your experience on metrical. You can also put a fake name or only your first name if you prefer.
* **Timezone**: we need this to group in the best way the data in our charts and also to understand what is the best moment to send our daily/weekly recaps.
* **The date of the last visit on our dashboard**: this is useful to understand if our paying users are using the service or they forgot about it, and in case ask if they want to cancel the subscription.
* All payments data are handled securely by [Stripe](https://stripe.com/) and we don't have any information about your credit/prepaid cards on our server.&#x20;

If you have any questions about how we handle user data and personal information, feel free to [contact us](mailto:hello@metrical.xyz).

If you continue to use our website we will assume that you accept our privacy policy and our practices for the handling of your personal information.

This policy is effective as of 01 February 2020.


# What we track

We are proud to collect only the bare minimum to give our users useful data but at the same time we don't store personal informations about your visitors.

Here is a list of what we do collect from your visitors:

### URLs

We store the URL of the current page viewed by your visitors. This will be useful to understand what pages are most visited on your website.

We store only the pathname, we don't store any query parameter (except `ref=`, `source` and `utm_source=`  that will be used for some better referrers in the future - **still WIP** but will be available before the beta ends)

So for a URL like this:

{% embed url="<https://example.com/category/page?page=2&search=private-search&userId=1234>" %}

We will only store (and use for our dashboard) only this:

{% embed url="<https://example.com/category/page>" %}

### Referrers

We store the referrer (the website or application that generated the visit) to let you know where your visitors come from.&#x20;

After store the referrer, we will analyze it and store it as one of 3 types:

* Direct visit, if there isn't a referrer. Please note that lots of email clients doesn't send a referrer when you click on a link, so it could be that some visits coming from newsletters may fall under this category.
* Organic: visits from search engine. Right now we place in this category visits from Google, Bing, DuckDuckGo, Yandex, Ecosia, Baidu, Yahoo and Coccoc.
* Referrers: visits from every other referrers.

### Device Width

We store the device width of the device of your visitors to let you know if your website is used more from a mobile device, a tablet or a laptop.

### Timezone

We store the timezone of your visitors to estimate the country of the visit. For example: if a visitors have a `Europe/Rome`  timezone, we assume that your visitor is from Italy [🇮🇹](https://emojipedia.org/flag-italy/).

## Do not Track

Do not Track is a settings in some browsers that, when you visit a website, ask the website to not track you. Unfortunately it's not really supported.

Metrical will honour the `Do not Track` setting and we don't send the visit when we find the `do not track` flag enabled.

If you wish to know more about 'Do not Track' and how to enable it on your browser, visit <https://allaboutdnt.com/>


# We don't use cookies

Lots of analytics services (like Google Analytics) use cookies or local storage to store some information about the visitors.

### What is a cookie?

A cookie is a series of information saved on your browser when you visits some websites.

When you do a login or a registration on a website, normally the website will store the information that you are currently logged in (and maybe your user ID, or other data to retrieve your account) in a cookie. This is a good thing and should be the only accepted way to use a cookie.&#x20;

Some websites and services use the cookies to store some informations to **track the user around the Internet**; due to the technical nature of cookies, a cookie stored on facebook.com could be used also on any other websites that request a resource (an ad, a banner, a fb login script...), so in this way it's possible to track all the websites visited by an Internet user.&#x20;

This is bad, mainly because this tracking is almost something invisible to the current user.&#x20;

### Metrical doesn't use any cookie to track your visits.

We don't like be tracked on every move that we do on the Internet. It's shady and we don't know how that data will be used. For this reason, we decided to store only some simple (and not-personal) data of the visitors and just in case we made it impossible, if somebody gains access to our server, to group the visits of a single user together. Every visit on Metrical is treated as unique, not as a series of visits of the same user.

To be able to do this, we decided to never use any cookie to track the visits.

### How we are still able to calculate unique visits and total pageviews without any cookie

Since the privacy and the respect of the user information is so important to Metrical, we want to be transparent on how we obtain our data.&#x20;

{% hint style="info" %}

### Session ID

We create a complex hash (a unique string of characters) based on&#x20;

* IP Address
* User Agent
* Site UUID
* Random SHA256 String stored securely on the Metrical Server
* The day of the year on our server / 2 (more on this below)

This is the sessionID. There isn't any way to decode the sessionId to retrieve the Ip Address, User Agent and the other data used. Also, using the Site UUID as a way to create the sessionId, we can't in any way correlate the same user on 2 different sites that are using Metrical to track their users.
{% endhint %}

Here are the steps that we do when we receive a visit from a user:

1. We calculate the session ID
2. We check if this session ID is already stored on a **sessions** table. This sessions table has only 2 fields: 'session' and 'createdAt' and it isn't in any way connected to the **visits** table.&#x20;
3. If the session ID isn't already stored, we add the sessionId in the table
4. We create the visit. If the sessionId wasn't already present on our sessions table, we will set the field 'firstVisit' to true. If the sessionId was already present on the table, it means that the user visited the website before in the last day, so the visit is only a pageview. **We don't save the sessionId as a field of the visit.**

#### Why we need the 'createdAt' value to the sessions table?

When we create a session, we want to be able to know when it was created so that every week the sessionIds that are older than 7 days (we don't need that). In this way the sessions table will only have data that are needed and will be faster to query it every time we store a visit.

####


