How to start measuring pageviews

Measing pageviews can be done in two ways. Both ways can be arranged that the second is a fallback for the other.


Using JavaScript

The most practical solutions is to use JavaScript. First, you insert the following line:

<script src="https://app.indiemetrics.net/hello.js"></script>


Now you can use ogma(...) as a global function. Now you set your siteId using:

ogma("create", "<your site id>");


And register the pageview using:

ogma("send", "pageview", [page (OPTIONAL)]);


As you can see, there is an optional parameter page. You can use this if you use client side rendering, for example using Angular. Standard Indiemetrics will use the current page as send by the server.


Using a hidden pixel

If the JavaScript method is not possible or desirable, Indiemetrics provides an image based alternative. Insert the following line into your html

<img src="https://app.indiemetrics.net/event/add?create=<SITE ID>&type=pageview&page=<CURRENT PAGE>" alt="Indiemetrics">


Et voilĂ , done.


Combining the two a.k.a. the fallback method

Both methods can be combines into the following:

<script src="https://app.indiemetrics.net/hello.js"></script>
<script> ogma("create", "<your site id>"); ogma("send", "pageview", [page (OPTIONAL)]); </script>
<noscript> <img src="https://app.indiemetrics.net/event/add?create=<SITE ID>&type=pageview&page=<CURRENT PAGE>" alt="Indiemetrics"> </noscript>