Display last update and visitors on Neocities

This guide is for publicly displaying a date your site was last updated and how many visitors you’ve had on your website.

It uses the technique as explained by Dannarchy here.

I just wanted to simplify it a bit and make it a little easier to implement if you’re not at a place where you can understand everything right away.

  • Go to the page you want to display this information and paste the following code:
<script> var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var site_data = JSON.parse(this.responseText); var num_arr = site_data.info.views.toString().split(""); var num_str = ""; for (i = 0; i < num_arr.length; i++) { num_str += num_arr[i]; if ( (num_arr.length-1 - i) % 3 == 0 && (num_arr.length-1 - i) != 0 ) {num_str += ",";} var date_str = site_data.info.last_updated; var date_obj = new Date(site_data.info.last_updated); document.getElementById("lastupdate").innerHTML = (date_obj.getMonth()+1) + "-" + date_obj.getDate() + "-" + date_obj.getFullYear(); } document.getElementById("hitcount").innerHTML = num_str; } }; xhttp.open("GET", "https://weirdscifi.ratiosemper.com/neocities.php?sitename=USERNAME", true); xhttp.send();</script>
Code language: JavaScript (javascript)
  • In the code above, change USERNAME to match your Neocities username.
  • Wherever you want to display the last update data, use this:
Last Updated: <span id="lastupdate"></span>
Code language: HTML, XML (xml)
  • Wherever you want to display your hit count, use this:
You are Visitor #: <span id="hitcount"></span>
Code language: HTML, XML (xml)

That’s all you need to do! If you’d like to learn more about how this works, definitely check out Dannarchy’s page.

Hey, thanks for reading! If you have any questions, you can leave me a comment and I always try to reply.

If you have any suggestions on how I can improve this article, please let me know!

This website is not monetized in any way. It purely exists to help others on their web-building journey. However, if you have the means to donate toward my server costs, I have a ko-fi account where I accept tips.

1 thought on “Display last update and visitors on Neocities”

Leave a Comment