DEV Community

Cover image for Simplest way to monitor visits on your website (No Purchase, No Sign Up)
Haris Ahmad
Haris Ahmad

Posted on

Simplest way to monitor visits on your website (No Purchase, No Sign Up)

Yes, you don't have to purchase an Analytics Service or sign up to some sketchy application just to know simple thing like how many visits did your site has. Just with a few lines of code you can easily find out the overall visit count of your website.

2 Steps to install this service

Step 1: Add the following JavaScript to your Website โš™๏ธ

Add the following code to your website where it is called every time a user visits (Could be your homepage). Replace [YOUR WEBSITE NAME] to your Website name or any other uniquely identifiable string

window.onload = function (){
    fetch('[YOUR WEBSITE NAME]/visits')
Enter fullscreen mode Exit fullscreen mode

Step 2: View the Page Visits ๐Ÿ•ต

To get the page view you can visit the following endpoint[YOUR WEBSITE NAME]/visits
Enter fullscreen mode Exit fullscreen mode

Waitโœ‹! but it might not be end for you

The example that I have provided is the bare minimum setup you need to do to monitor the visits. You might want to monitor the visits on each page of your site separately or want to have rather complex analytics. Thanks to CountAPI which gives us this tooling for free. For more complex 'Visit Analytics', please go ahead and read the docs from CountAPI

Liked the solution?

If you liked the post you can read more from me. For more please follow me on my social media handles provided below


Top comments (2)

andrewbaisden profile image
Andrew Baisden

Cool tip!

harisahmadev profile image
Haris Ahmad

Glad you liked it :)