Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
Count the number of users
  • Loading branch information
AB3462461320878 authored Oct 21, 2023
1 parent 730abcf commit b26a726
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,36 @@ <h1 style="text-align: center; color: white; font-family: raleway;">Pictures fro


<!-- Org --------------------------------------------------------------------------------------------------- -->
<div class="Costumer-CC">
<p class="Costumer-message">Thank you User Number : <span id="userCount">Loading...</span> For visiting Us</p>

<script>
// Function to fetch the real-time user count from Google Analytics
function fetchUserCount() {
gapi.client.analytics.data.realtime.get({
ids: 'ga:YOUR_VIEW_ID', // Replace with your View ID
metrics: 'rt:activeUsers'
}).then(function(response) {
var activeUsers = response.result.rows[0][0];
document.getElementById('userCount').textContent = activeUsers;
});
}

// Load the Google Analytics library
gapi.load('client', function() {
gapi.client.init({
apiKey: 'YOUR_API_KEY' // Replace with your API key
}).then(function() {
fetchUserCount();
// Refresh user count every 60 seconds (adjust as needed)
setInterval(fetchUserCount, 60000);
});
});
</script>

<script src="https://apis.google.com/js/client.js?onload=fetchUserCount"></script>

</div>
</body>

</html>
Expand Down

0 comments on commit b26a726

Please sign in to comment.