# Download tracker plugin

**URL:** https://meta.discourse.org/t/download-tracker-plugin/274832
**Category:** Support
**Created:** [August 11, 2023, 5:33pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832 "2023-08-11T17:33:49Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![AndyBr](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@AndyBr](https://meta.discourse.org/u/AndyBr)
#### Post date: [August 11, 2023, 5:33pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/1 "2023-08-11T17:33:50Z")

</div>

Does anyone know of a plugin or mod that will keep track of which user clicked a link or downloaded an attached file?

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [August 11, 2023, 5:43pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/2 "2023-08-11T17:43:27Z")

</div>

i suspect you probably need to use [google tag manager](https://tagmanager.google.com/) for this. Discourse itself doesn’t track individual user’s clicks (it tracks topic views and link click counts by users as a whole) and i haven’t seen a plugin that does this sort of tracking at the individual user level.

---

<div class="post-metadata">

### Author: ![AndyBr](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@AndyBr](https://meta.discourse.org/u/AndyBr)
#### Post date: [August 11, 2023, 5:58pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/3 "2023-08-11T17:58:00Z")

</div>

TY. Was hoping someone had created something like this that works with the latest Discourse…

> **[«Restricted Files» plugin (version 2.1, 2016-12-11)](https://discourse.pro/t/topic/33)**
>
> The «Restricted Files» plugin allows you to restrict access to downloads (attached files) so only users of permitted groups can download files from your Discourse forum. So you can sell digital content through your Discourse forum. To receive...

Don’t really need the restrictions, just the logging of who downloaded what.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 11, 2023, 11:57pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/4 "2023-08-11T23:57:48Z")

</div>

If you have a budget you can post in #Marketplace or contact me. I have no idea what it would take without looking at the code. Links get tracked, so it should be possible to also log who clicked them. Downloads will likely be harder.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [August 12, 2023, 5:41am UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/5 "2023-08-12T05:41:11Z")

</div>

FWIW There’s the `topic_link_clicks` table with a bit more info in, though I think it has the limitation of only counting direct clicks and not eg. ‘right click and open’.

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [August 12, 2023, 6:09am UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/6 "2023-08-12T06:09:30Z")

</div>

oh i didn’t think it tracked the user info but i see now there is a user\_id field in the table 👍 interesting 🧐

---

<div class="post-metadata">

### Author: ![AndyBr](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@AndyBr](https://meta.discourse.org/u/AndyBr)
#### Post date: [August 12, 2023, 2:44pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/7 "2023-08-12T14:44:55Z")

</div>

Oh!  
Could someone kind person with more SQL chops than me create a query that would list the post, link and username?  
(I have the DataExplorer Plugin for running queries)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [August 13, 2023, 9:05pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/8 "2023-08-13T21:05:25Z")

</div>

Something like this should do it:

```sql
-- [params]
-- int :topic
-- int :post_number

SELECT 
    tl.post_id,
    tl.url,
    tlc.user_id
FROM topic_link_clicks tlc
  JOIN topic_links tl ON tl.id = tlc.topic_link_id
  JOIN posts p ON p.id = tl.post_id
WHERE p.topic_id = :topic 
  AND p.post_number = :post_number
  AND tlc.user_id IS NOT NULL
ORDER BY tlc.id

```

You can use the topic id and post number from the address bar to pull up all the users who clicked on the links in a specific post (you may need to refresh the page once you paste it in to get the parameter input boxes to show up the first time).

Hopefully that helps. 🙂

---

<div class="post-metadata">

### Author: ![AndyBr](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@AndyBr](https://meta.discourse.org/u/AndyBr)
#### Post date: [August 13, 2023, 9:29pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/9 "2023-08-13T21:29:10Z")

</div>

TY. Works fine!  
Seems to me that a plugin that would show who clicked any link in a post would be quite easy to make (for someone that knows how to make plugins)  
Ideally, hovering over the number would pop-up the list of who clicked, with a little “copy” icon in the corner! 🙂

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [August 13, 2023, 9:51pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/10 "2023-08-13T21:51:32Z")

</div>

> [@AndyBr](#):
>
> Ideally, hovering over the number would pop-up the list of who clicked, with a little “copy” icon in the corner! 🙂

this sounds similar to some of the like/reaction button functionality

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 14, 2023, 12:31am UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/11 "2023-08-14T00:31:12Z")

</div>

> [@AndyBr](#):
>
> Ideally, hovering over the number would pop-up the list of who clicked, with a little “copy” icon in the corner!

That’s possible, you’d need to add that list to the topic serializer.

---

<div class="post-metadata">

### Author: ![AndyBr](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@AndyBr](https://meta.discourse.org/u/AndyBr)
#### Post date: [August 14, 2023, 2:09pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/12 "2023-08-14T14:09:29Z")

</div>

Anyone feel like having a crack at it?

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [August 14, 2023, 2:23pm UTC](https://meta.discourse.org/t/download-tracker-plugin/274832/13 "2023-08-14T14:23:14Z")

</div>

you may want to post this in #Marketplace to get some interest for developers
