Misframe

Jan 7, 2017

New project: Alpha analytics

I have a new project! It’s called Alpha. Since the last project I started is called Epsilon (for events), I decided to call this Alpha for… analytics! Alpha is an extremely simplified version of Google Analytics. I know very little about website / browser analytics, so building something like this is a great way to learn.

It’s up and running right now. If you’re reading this post on the Misframe site, you’ll see this snippet on the bottom of the page:

<script>
(function() {
  var e = document.createElement('script');
  e.type = 'text/javascript';
  e.src = 'https://alpha.infinitynorm.com/t.js';
  e.async = true;
  document.body.appendChild(e);
})();
</script>

Here’s what I want to get out of working on this project:

Here’s a preview of the web app I’m writing for Alpha:

It’s not great, but it’s a start! The time series are generated using an Epsilon query. Because Alpha stores raw events in Epsilon, I get to slice and dice this data any way I want. Everything is stored using lm2.


Note 1

Did you know Googlebot runs JavaScript? I ran the equivalent of this SQL on Epsilon:

SELECT COUNT(*) FROM events GROUP BY user_agent
{
  "data": {
    "query": {
      "columns": [
        {
          "aggregate": "count",
          "name": "_id"
        }
      ],
      "descending": false,
      "group_by": [
        "user_agent"
      ],
      "order_by": [
        "count(_id)"
      ],
      "time_range": {
        "end": 9223372036854775807,
        "start": 0
      }
    },
    "summary": [
      {
        "count(_id)": 44,
        "user_agent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +https://www.google.com/bot.html)"
      },
      {
        "count(_id)": 90,
        "user_agent": "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +https://www.google.com/bot.html) Safari/537.36"
      }
	  // Others that I manually removed since Epsilon doesn't have a regexp filter yet :).
    ]
  }
}

Note 2

Another version of this project started as a way to track my own website usage. I used a browser extension to inject the tracking code into every page I visited. I ended up finding a security issue in VividCortex this way šŸ˜¬ . Make sure you’re using CSP policies in your applications!

Next read these:
Nov 23, 2023
Jan 11, 2023
Apr 9, 2016