Total Visitors

Counting the total visitors on my website and picturize the data by using chart.js graph

Suboor Khan
Suboor Khan

Suboor Khan

Software Engineer


A website visitor is someone who views/goes to your website. In our weekly email stats this is the number of unique visits your website had during that weekly period. If that visitor views multiple pages on your website, that still only counts as 1 visit. Additionally, if the visitor leaves your website and comes back within that same week period this is all still counted only once as 1 visitor.



Counting Visits To Your Website


There are different ways to count visits to a website. In order to count visits, some code needs to be present to collect data that will measure “hits.” As user’s attention has become increasingly focused on privacy, many people utilize blockers or browsers which prevent their internet activity from being measured by Google and some other services.

Google Analytics (GA) is the standard for measuring website traffic. GA provides an amazing amount of data and is the best way to count website visits for curiosity and to measure results of marketing efforts.

You can install a statistics package on your server on your own to check website visitors. This would allow a more accurate accounting of website visitors.

AWStats is a program that is included by many web hosts who use cPanel, however, you can also install it yourself. The visitor stats this package provides should provide a reasonable estimate of visits for the purposes of sizing a hosting plan.

------------------------------------------------------------

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body>

<img src="" id="img" alt="">
<button onclick="handleNextClick()">next</button>
</body>

<script>
let allImages = [];
let currentImageIndex = 0;


const main = async () => {
const res = await fetch('https://dummyjson.com/products');
const data = await res.json();
const {
products
} = data;

const productsFilterByPrice = (price) => {
const result = products.filter((product) => {
if (product.price <= price) {
return product
}
});
return result
}

console.log(productsFilterByPrice(10));

const getProductById = (id) => {
const result = products.find((product) => {
if (product.id === id) {
return product
}
});
return result;
}
console.log(getProductById(5));

const addTen = (num) => {
const result = products.map((product) => {
return {
...product,
price: product.price + num
}
})
return result;
}

console.log(addTen(100))

const prodNameToArr = () => {
const result = products.map((product) => {
return product.thumbnail
})

return result;
}


allImages = prodNameToArr();
console.log(allImages)
document.getElementById('img').src = allImages[0]

}

function handleNextClick() {
const img = allImages[currentImageIndex + 1];
document.getElementById('img').src = img;
currentImageIndex++;
}


main();
</script>

</html>


HomeNews feedsWorkSessionsContact