Oct 28, 2020

TinyAnalytics - Made with PHP and Javascript

Recently,  I forked and updated TinyAnalytics to make it full PHP on the back side and Javascript on the front.

For a small/medium size project, Google Analytics is definitely an overkill and it's also been blocked by more and more ad blockers.


There are three easy steps:

  • Unzip this package to a host accessible with https.
  • Add the following tracking code to your websites at the end of files and modify myhost and my-web-site:

    const xhr = new XMLHttpRequest();
    xhr.open('POST', 'https:// myhost /req.php');
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.send(JSON.stringify({ "sn": "my-website-name", "ref": document.referrer }));

  • Modify your password in config.php and set the allowed domains there.

It's done! Visit at least one of your tracked websites, and open https:// myhost /index.php in your browser!

It's here: https://github.com/Wanchai/PHP-JS-TinyAnalytics

Tell me what you think!

No comments:

Post a Comment