All Projects â†’ brentvollebregt â†’ Hit Counter

brentvollebregt / Hit Counter

Licence: mit
Easily count hits 📈 on a website by requesting a SVG displaying hit count 🎯

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Hit Counter

Reactnative Animation Challenges
A series of animation challenges in React Native.
Stars: ✭ 352 (+241.75%)
Mutual labels:  counter
Multipletimers
Stars: ✭ 24 (-76.7%)
Mutual labels:  counter
Spincounterview
🎡 侀äžȘ类䌌äșŽç èĄšć˜ćŒ–çš„æ—‹èœŹèźĄæ•°ć™šćŠšç”»æŽ§ä»¶
Stars: ✭ 47 (-54.37%)
Mutual labels:  counter
Goodshare.js
🚀 А useful modern JavaScript solution for share a link from your website to social networks or mobile messengers. Easy to install and configuring on any of your website!
Stars: ✭ 420 (+307.77%)
Mutual labels:  counter
Counterfab
A FloatingActionButton subclass that shows a counter badge on right top corner
Stars: ✭ 725 (+603.88%)
Mutual labels:  counter
Vue Twitter Counter
Counter component inspired in Twitter with Vue
Stars: ✭ 29 (-71.84%)
Mutual labels:  counter
stats
📊 Request statistics middleware that stores response times, status code counts, etc
Stars: ✭ 15 (-85.44%)
Mutual labels:  counter
Social Links
Simple library to count shares and generate share buttons
Stars: ✭ 91 (-11.65%)
Mutual labels:  counter
Github Profile Views Counter
It counts how many times your GitHub profile has been viewed. Free cloud micro-service.
Stars: ✭ 781 (+658.25%)
Mutual labels:  counter
Inferno Most Fp Demo
A demo for the ReactJS Tampa Bay meetup showing how to build a React+Redux-like architecture from scratch using Inferno, Most.js, reactive programmning, and various functional programming tools & techniques
Stars: ✭ 45 (-56.31%)
Mutual labels:  counter
Flip
⏳ The online version of the classic flip clock
Stars: ✭ 460 (+346.6%)
Mutual labels:  counter
Laravel Visits
📊 Laravel Visits is a counter that can be attached to any model to track its visits using Redis or Eloquent. (with tags, IP protection and caching)
Stars: ✭ 582 (+465.05%)
Mutual labels:  counter
App
Just a little analytics insight for your personal or indie project
Stars: ✭ 40 (-61.17%)
Mutual labels:  counter
Eloquent Viewable
Associate views with Eloquent models in Laravel
Stars: ✭ 404 (+292.23%)
Mutual labels:  counter
React Countup
đŸ’« A configurable React component wrapper around CountUp.js
Stars: ✭ 1,063 (+932.04%)
Mutual labels:  counter
Metric
Minimal metrics for Go (counter/gauge/histogram). No dependencies. Compatible with expvar. Web UI included.
Stars: ✭ 319 (+209.71%)
Mutual labels:  counter
Madoka Python
Memory-efficient Count-Min Sketch Counter (based on Madoka C++ library)
Stars: ✭ 24 (-76.7%)
Mutual labels:  counter
Dipstick
Configurable metrics toolkit for Rust applications
Stars: ✭ 92 (-10.68%)
Mutual labels:  counter
Xena
Lightweight, lighting-fast Java Based Cross-Platform CSGO Cheat
Stars: ✭ 69 (-33.01%)
Mutual labels:  counter
Omg Counters
😍 Increment decrement counters using various frontend frameworks.
Stars: ✭ 44 (-57.28%)
Mutual labels:  counter

Hit Counter

Easily count hits on a website by requesting a SVG that displays a hit count.

Hits

Live demo hosted at: hitcounter.pythonanywhere.com

Please note this is only a demo instance and any traffic that causes harm to the server will be blocked. Also due to how this demo instance is being hosted and the large amount of traffic it gets, the server does fall over some times.

What is This?

This is a server that allows a client to request for an SVG file that displays views for a URL. This URL can either be passed as a query parameter or the referrer (or referer) value in the header will be used.

A small method to help prevent the count increasing after short consecutive page loads is included which uses cookies to check if the user has made the request recently.

This makes it very easy to keep track of views on static sites like Github Pages. It can also be used on non-static sites as a general counter.

How Can I Use it?

Getting an SVG

To get an image for the current URL (for example is image is being requested by www.example.com), simply get the image as you normally would:

<img src="https://hitcounter.pythonanywhere.com/count/tag.svg" alt="Hits">

In this example, a hit would be added to the websites count on the server. To stop this from occurring but still get the SVG file, use:

<img src="https://hitcounter.pythonanywhere.com/nocount/tag.svg" alt="Hits">

Warning: "Chrome plans to radually enable strict-origin-when-cross-origin as the default policy in 85; this may impact use cases relying on the referrer value from another origin". To get around this, you'll want to put the URL in the query string as outlined under Getting a Count For a Site That Isn't Me.

Getting the Count Raw

If you don't want the SVG file but still want the count to use in something else, you can do a GET request to /count or as before, /nocount to not add a count. For Example:

let xmlHttp = new XMLHttpRequest();
xmlHttp.withCredentials = true;
xmlHttp.open('GET', 'https://hitcounter.pythonanywhere.com/count', false);
xmlHttp.send(null);
count = xmlHttp.responseText;

Using Ajax

let targetUrl = window.location.href;
$.ajax('https://hitcounter.pythonanywhere.com/count', {
    data: { url: targetUrl },
    xhrFields: { withCredentials: true }
}).then(count => console.log('Count:' + count));

Do not use data: {url: encodeURIComponent(targetUrl)} as Ajax will encode the string (url) for you. Doing this will encode the url twice which will then only be decoded on the server once (this can lead to broken tags in the future).

Getting a Count For a Site That Isn't Me

There may be circumstances that the referrer may not be sent or you may want to request an SVG or count for another site. To do this, set url to the URL you want to get (make sure to encoded the value).

For example, getting an SVG:

<img src="https://hitcounter.pythonanywhere.com/nocount/tag.svg?url=www.example.com" alt="Hits">

And if you want to get the count:

let targetUrl = 'www.example.com';
let query = '?url=' + encodeURIComponent(targetUrl);
let xmlHttp = new XMLHttpRequest();
xmlHttp.withCredentials = true;
xmlHttp.open('GET', 'https://hitcounter.pythonanywhere.com/nocount' + query, false);
xmlHttp.send(null);
count = xmlHttp.responseText;

There are also some situations where a client will not send the Referer in the header. This is a simple solution to the server not being able to find where the request came from.

Generating Links With A Tool Hosted By The Server

Going to the location / on the server, you will be served with an HTML page that contains a tool to create the image tag or markdown element and search up a websites count.

Interface

Documentation

Inspiration

This project was inspired by github.com/dwyl/hits which is a "General purpose hits (page views) counter" which unfortunately will only count GitHub repo views. This was my idea to expand on this and add some features with also making it compatible with any site.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].