# Implementing a simple page-counter in Elements?

**URL:** <https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264>\
**Category:** Elements\
**Created:** [December 17, 2025, 3:40pm UTC](https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264 "2025-12-17T15:40:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elementor](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Elementor](https://forums.realmacsoftware.com/u/Elementor)\
**Post date:** [December 17, 2025, 3:40pm UTC](https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264/1 "2025-12-17T15:40:39Z")

</div>

Maybe a good thing to implement. A simple page-counter within elements, just to have an easy access to the number of visitors …

---

<div class="post-metadata">

**Author:** ![Doobox](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/doobox/32/32373_2.png) [@Doobox](https://forums.realmacsoftware.com/u/Doobox)\
**Post date:** [December 17, 2025, 3:52pm UTC](https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264/2 "2025-12-17T15:52:09Z")

</div>

You can make a simple custom component. You will just need to change the tailwind text colour class to what you want.

 ![CleanShot 2025-12-17 at 3 .49.47@2x](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/3X/8/7/870c2e23467fd41623c4fdc42b7b6a9aa037fe20.png)

```javascript
<span id="counter" class="text-text-500">Page Visits: </span>

<script>
const key = "pageVisits:" + location.pathname;
const visits = (localStorage[key] = (+localStorage[key] || 0) + 1);
document.getElementById("counter").textContent = "Page visits: " + visits;
</script>

```

---

<div class="post-metadata">

**Author:** ![Elementor](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Elementor](https://forums.realmacsoftware.com/u/Elementor)\
**Post date:** [December 17, 2025, 3:57pm UTC](https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264/3 "2025-12-17T15:57:01Z")

</div>

> [@Doobox](#):
>
> You will just need to change the tailwind text colour class to what you want.

Thank you Doobox

I use a lot of your apps in RW and it was my motivation to get something similar to your app 😉 Greetings to Jersey

---

<div class="post-metadata">

**Author:** ![Doobox](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/doobox/32/32373_2.png) [@Doobox](https://forums.realmacsoftware.com/u/Doobox)\
**Post date:** [December 17, 2025, 4:03pm UTC](https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264/4 "2025-12-17T16:03:21Z")

</div>

Bettor version that purposely only works in the published page. Else while developing teh site you will be crating local storage keys that become entirely redundant after publishing.

```javascript
<span id="counter" class="text-text-500">Page Visits: (0)</span>

@if(!preview) 
<script>
const key = "pageVisits:" + location.pathname;
const visits = (localStorage[key] = (+localStorage[key] || 0) + 1);
document.getElementById("counter").textContent = "Page visits: " + visits;
</script>
@endif

```

---

<div class="post-metadata">

**Author:** ![Elementor](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Elementor](https://forums.realmacsoftware.com/u/Elementor)\
**Post date:** [December 17, 2025, 4:09pm UTC](https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264/5 "2025-12-17T16:09:47Z")

</div>

Very nice move. Thank you very much. If I can help you as a Corporate Designer - I gladly will do so.

---

<div class="post-metadata">

**Author:** ![Doobox](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/doobox/32/32373_2.png) [@Doobox](https://forums.realmacsoftware.com/u/Doobox)\
**Post date:** [December 17, 2025, 4:11pm UTC](https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264/6 "2025-12-17T16:11:01Z")

</div>

Wait Noooooo!

I’ve lost the plot. This will only work per visitor.

For all visitors to see the real page views a server side php solution is needed.

---

<div class="post-metadata">

**Author:** ![Elementor](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Elementor](https://forums.realmacsoftware.com/u/Elementor)\
**Post date:** [December 17, 2025, 4:13pm UTC](https://forums.realmacsoftware.com/t/implementing-a-simple-page-counter-in-elements/53264/7 "2025-12-17T16:13:43Z")

</div>

So i wait patiently till you develop a add on for elements 🙂
