Skip to content
This repository was archived by the owner on Sep 12, 2025. It is now read-only.

david-prv/visitor.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

visitor.js

simple self-hosting visitor tracking library in javascript

Installation

  1. Upload files to your server
  2. Edit them and adjust relative paths
  3. Import DB Structure
  4. Include script to your project
  5. You are done

How to use

Embed the following code into your footer
Compressed:

<!-- Begin Visitor Count -->
    <script id="vc-src" src="PATH_TO_YOUR_CWD/visitorjs/ajax.js"></script>
    <script id="ajax-src" src="PATH_TO_YOUR_CWD/visitorjs/visitor.js"></script>
    <script type="text/javascript">let counter=new VisitorCounter("exact_loc",function(e){console.log(e)});counter.make();</script>
<!-- End Visitor Count -->

Fullscale:

<!-- Begin Visitor Count -->
  <script id="vc-src" src="PATH_TO_YOUR_CWD/visitorjs/ajax.js"></script>
  <script id="ajax-src" src="PATH_TO_YOUR_CWD/visitorjs/visitor.js"></script>
  <script type="text/javascript">
      // initialize counter
      let counter = new VisitorCounter('exact_loc', function(data) { console.log(data); });

      // start counting
      counter.make();
  </script>
<!-- End Visitor Count -->

In Case you want to display the current visitor count, use .useContainer() before you call .make(). Read more about that below.

VisitorCounter Settings

new VisitorCounter(LOCATION, CALLBACK, TEST);

@param {string} LOCATION: exact_loc | host_only

Track the exact location or the hostname
(e.g track https://www.google.com instead of https://www.google.com/search?q=a)

@param {callback} CALLBACK: any function, receives server reply as data

Callback Function for Ajax Call to backend API which receives an argument called 'data' containing the server's answer

@param {boolean} TEST: true | false

Enable this to prevent database spam when working on the tracked site. This option will disable actual tracking

Containments Settings

myCounter.useContainer(ELEMENT);

@param {external:Node} ELEMENT: null | any node

Pass this in case you want to use an own container element. If you leave it empty, it will fallback to standard element with id 'visitor-count'.

About

simple self-hosting visitor tracking library in javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published