Giter Club home page Giter Club logo

visitor.js's Introduction

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'.

visitor.js's People

Contributors

david-prv avatar

Stargazers

Nolan Bjarne avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.