# See who viewed topic

**URL:** https://meta.discourse.org/t/see-who-viewed-topic/29277
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [May 26, 2015, 8:37pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277 "2015-05-26T20:37:07Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Ethosyde](https://avatars.discourse-cdn.com/v4/letter/e/65b543/32.png) [@Ethosyde](https://meta.discourse.org/u/Ethosyde)
#### Post date: [May 26, 2015, 8:37pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/1 "2015-05-26T20:37:07Z")

</div>

Is there a way to see all users that viewed a topic? Just curious who is viewing and not replying.

if there is a way, can it be locked to a certain security group?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 26, 2015, 8:42pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/2 "2015-05-26T20:42:37Z")

</div>

This data is in the database but there is no UI to view it.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [May 26, 2015, 8:46pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/3 "2015-05-26T20:46:57Z")

</div>

This could be a nice item for the admin/wrench menu some day…

---

<div class="post-metadata">

### Author: ![Ethosyde](https://avatars.discourse-cdn.com/v4/letter/e/65b543/32.png) [@Ethosyde](https://meta.discourse.org/u/Ethosyde)
#### Post date: [May 27, 2015, 7:39pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/4 "2015-05-27T19:39:54Z")

</div>

Since this is not an ability to use via the UI. Should this topic be moved over to the suggestions category?

Thanks for replying, awesome support. Very much appreciate everyone here. Its crazy how awesome support is compared to all other companies, this is what sets Discourse apart from others on top of the forum itself. great , great, great!!!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 16, 2016, 9:54am UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/5 "2016-05-16T09:54:53Z")

</div>

We are looking at this for personal messages, specifically, where staff can check to see who has seen important messages.

---

<div class="post-metadata">

### Author: ![Ernie](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@Ernie](https://meta.discourse.org/u/Ernie)
#### Post date: [July 3, 2017, 8:04pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/6 "2017-07-03T20:04:28Z")

</div>

I see there’s be no message traffic on this post for some time. And, there is still no ability to see who has viewed posts. I can understand why this might be a bit unwieldy is lots of people viewed a particular topic, but if the list was small, it would be good a moderator to be able to see who looked and did nothing more. IMHO.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [July 3, 2017, 9:15pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/7 "2017-07-03T21:15:39Z")

</div>

I don’t know how much work, if any, has gone into making this a feature. But if you use the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) plugin you can query the `topic_users` table to find out who has seen a topic. Maybe `JOIN` with the `posts` table to see who has visited the topic and who has posted a reply in it?

---

<div class="post-metadata">

### Author: ![aksoforever](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aksoforever/32/502615_2.png) [@aksoforever](https://meta.discourse.org/u/aksoforever)
#### Post date: [June 20, 2019, 12:16am UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/8 "2019-06-20T00:16:39Z")

</div>

Hi，Jeff，  
Someway，how can we see what topic some user have viewed？  
thank you

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [June 20, 2019, 8:29am UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/9 "2019-06-20T08:29:45Z")

</div>

Yes, you can do this with the [Data Explorer Plugin](https://meta.discourse.org/t/what-cool-data-explorer-queries-have-you-come-up-with/43516); which means, only staff can do it.

---

<div class="post-metadata">

### Author: ![aksoforever](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aksoforever/32/502615_2.png) [@aksoforever](https://meta.discourse.org/u/aksoforever)
#### Post date: [June 20, 2019, 10:56pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/10 "2019-06-20T22:56:05Z")

</div>

thanks，it helps me。😃

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [May 14, 2021, 10:46pm UTC](https://meta.discourse.org/t/see-who-viewed-topic/29277/11 "2021-05-14T22:46:47Z")

</div>

> [@tophee](#):
>
> Yes, you can do this with the [Data Explorer Plugin](https://meta.discourse.org/t/what-cool-data-explorer-queries-have-you-come-up-with/43516)

I’ve got a [Data Explorer](https://meta.discourse.org/t/32566?silent=true) query for this (which shows username to enable csv / groups / pms stuff):

```plaintext
-- Who viewed this topic? https://meta.discourse.org/t/see-who-viewed-topic/29277/11
-- [params]
-- int :topic_id
SELECT tu.user_id, u.username, total_msecs_viewed/1000 AS seconds_viewed
FROM topic_users tu
JOIN users u ON tu.user_id = u.id
WHERE tu.topic_id = :topic_id
    AND total_msecs_viewed > 0
GROUP BY tu.user_id, u.username, tu.total_msecs_viewed
ORDER BY tu.total_msecs_viewed desc

```

If it is okay in your context to reveal email addresses, then I suggest this one instead:

```plaintext
-- Who viewed this topic? With emails. https://meta.discourse.org/t/see-who-viewed-topic/29277/11
-- [params]
-- int :topic_id
SELECT tu.user_id, email, total_msecs_viewed/1000 AS seconds_viewed
FROM topic_users tu
JOIN user_emails ue ON tu.user_id = ue.user_id
WHERE tu.topic_id = :topic_id
    AND total_msecs_viewed > 0
GROUP BY tu.user_id, ue.email, tu.total_msecs_viewed
ORDER BY tu.total_msecs_viewed desc

```
