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('https://api.countapi.xyz/hit/[YOUR WEBSITE NAME]/visits')
}
Step 2: View the Page Visits ๐ต
To get the page view you can visit the following endpoint
https://api.countapi.xyz/get/[YOUR WEBSITE NAME]/visits
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
Blog๐ https://hariscodes.com/
Twitter๐ https://twitter.com/tweetharisahmad
Instagram๐ https://www.instagram.com/hariscodes/
Top comments (2)
Cool tip!
Glad you liked it :)