Skip to content

CurtisLusmore/logs

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Logs

A DIY page view logger, built with Azure Functions and Azure Table Storage, that records the pathname and referrer of all page views on your website. This is ideal for static websites like blogs, and where you are concerned about the privacy of more sophisticated tools like Google Analytics.

Note that this is not a fully-featured analytics suite that can track things like bounce rates, session times, navigation flows, etc. If you need this kind of information, you will need to either build it in yourself, or more likely, use another service altogether.

Dependencies

In order to deploy this you will need the following tools:

Deployment

To deploy, simply run the Deploy.ps1 file and supply the required values for the names of the various resources as prompted.

$ .\Deploy.ps1

Adding to website

Once you have deployed the infrastructure, add the following JavaScript snippet to your website to log a page view.

(function () {
  if (navigator.doNotTrack === '1') return;
  const payload = {
    pathname: document.location.pathname,
    referrer: document.referrer
  };
  navigator.sendBeacon(
    'https://your-deployment.azurewebsites.net/api/log',
    JSON.stringify(payload)
  );
}());

This snippet can also be found in ./js/log.js.

Custom Domain

To add a custom domain to the logging endpoint, follow the instructions on Map an existing Custom DNS name to Azure App Service to register a custom domain name, and then follow the instructions on Create a free certificate to create and assign a certificate to enable TLS.

About

DIY page analytics for static websites

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published