# Dashboard visitor counter

**URL:** https://discourse.nodered.org/t/dashboard-visitor-counter/3463
**Category:** Dashboard
**Created:** [26 September 2018 13:06 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463 "2018-09-26T13:06:54Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![b35b5dad43ea282b65d0](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@b35b5dad43ea282b65d0](https://discourse.nodered.org/u/b35b5dad43ea282b65d0)
#### Post date: [26 September 2018 13:06 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/1 "2018-09-26T13:06:54Z")

</div>

Hi,  
I want to ask if you know a way how to make a counter for the Dashboard.  
So every user who visits the dashboard counts up.  
Thanks

---

<div class="post-metadata">

### Author: ![Balouzard](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/balouzard/32/2869_2.png) [@Balouzard](https://discourse.nodered.org/u/Balouzard)
#### Post date: [26 September 2018 13:22 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/2 "2018-09-26T13:22:12Z")

</div>

Hello there,  
There are some ways to do that.  
When you say "user" you mean different people or for each visit increment the counter ?

---

<div class="post-metadata">

### Author: ![b35b5dad43ea282b65d0](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@b35b5dad43ea282b65d0](https://discourse.nodered.org/u/b35b5dad43ea282b65d0)
#### Post date: [26 September 2018 13:30 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/3 "2018-09-26T13:30:22Z")

</div>

Yes 😉  
Sorry i mean visitors not user.

---

<div class="post-metadata">

### Author: ![b35b5dad43ea282b65d0](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@b35b5dad43ea282b65d0](https://discourse.nodered.org/u/b35b5dad43ea282b65d0)
#### Post date: [26 September 2018 13:45 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/4 "2018-09-26T13:45:39Z")

</div>

Is there a good tutorial anywhere, i can not find anything for node-red.  
Is it for example possible to analyse the datas with google analytics?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [26 September 2018 15:18 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/5 "2018-09-26T15:18:23Z")

</div>

depends how accurate you want it... - the ui\_control node does provide an output for every browser connection (and disconnection etc) - so you could use that to trigger a count - but the same browser doing a full refesh will also count as a new connection so may over count.... but hey may be close enough.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [26 September 2018 15:25 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/6 "2018-09-26T15:25:49Z")

</div>

You mention Google Analytics - you can embed the necessary GA code via a ui\_template node to inject it in the head of the page. No need to build anything in NR itself.

---

<div class="post-metadata">

### Author: ![b35b5dad43ea282b65d0](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@b35b5dad43ea282b65d0](https://discourse.nodered.org/u/b35b5dad43ea282b65d0)
#### Post date: [28 September 2018 07:08 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/7 "2018-09-28T07:08:42Z")

</div>

So you think i can copy paste the code from google analytics gtag.js into the ui\_template.js and the it should work?

---

<div class="post-metadata">

### Author: ![Balouzard](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/balouzard/32/2869_2.png) [@Balouzard](https://discourse.nodered.org/u/Balouzard)
#### Post date: [28 September 2018 08:13 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/8 "2018-09-28T08:13:38Z")

</div>

That's what the man said 😄  
Try it and let us know how it turned out

---

<div class="post-metadata">

### Author: ![b35b5dad43ea282b65d0](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@b35b5dad43ea282b65d0](https://discourse.nodered.org/u/b35b5dad43ea282b65d0)
#### Post date: [28 September 2018 08:30 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/9 "2018-09-28T08:30:37Z")

</div>

I tried it with the template.js & template.html but both of them didnt work.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 September 2018 08:40 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/10 "2018-09-28T08:40:55Z")

</div>

What exactly do you mean when you say you pasted it in `ui_template.js` ? Do you mean you literally edited the file?

The suggestion is you drag a ui\_template node into your flow and paste the GA code into the contents of the ui\_template node so it gets added to your dashboard.

---

<div class="post-metadata">

### Author: ![Balouzard](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/balouzard/32/2869_2.png) [@Balouzard](https://discourse.nodered.org/u/Balouzard)
#### Post date: [28 September 2018 08:51 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/11 "2018-09-28T08:51:38Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/bdad84f63b48ee0fbc71fdc89574739228f02457.png)  
This is what @knolleary meant

---

<div class="post-metadata">

### Author: ![b35b5dad43ea282b65d0](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@b35b5dad43ea282b65d0](https://discourse.nodered.org/u/b35b5dad43ea282b65d0)
#### Post date: [28 September 2018 08:52 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/12 "2018-09-28T08:52:06Z")

</div>

Ah.  
I thought i need to edit the file.  
How exactly do i need to implement the ui\_template into my flow.  
Because i made 3 different flows for the same dashboard.

@Balouzard  
Thanks now it works.

---

<div class="post-metadata">

### Author: ![Balouzard](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/balouzard/32/2869_2.png) [@Balouzard](https://discourse.nodered.org/u/Balouzard)
#### Post date: [28 September 2018 08:54 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/13 "2018-09-28T08:54:13Z")

</div>

the `ui_template` node will refer to the dashboard `<head></head>`part of the code, doesn't matter how many flows you have created nor how many flows your dashboard refers to

---

<div class="post-metadata">

### Author: ![b35b5dad43ea282b65d0](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@b35b5dad43ea282b65d0](https://discourse.nodered.org/u/b35b5dad43ea282b65d0)
#### Post date: [28 September 2018 08:59 UTC](https://discourse.nodered.org/t/dashboard-visitor-counter/3463/14 "2018-09-28T08:59:56Z")

</div>

So its really easy to implement Google Analytics to the Node-Red dashboard.  
 ![37](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b9943743be933f9de5967421a9d446480eb10407.png)

![21](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/98b1ebf46c6e725694a19df68ab8779d772efb0f.png)

Thanks for your help.
