# Aggregated click number on forum click counter

**URL:** https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846
**Category:** Feature
**Created:** [March 26, 2015, 9:23pm UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846 "2015-03-26T21:23:17Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Tiffany\_Stelman](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@Tiffany\_Stelman](https://meta.discourse.org/u/Tiffany_Stelman)
#### Post date: [March 26, 2015, 9:23pm UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846/1 "2015-03-26T21:23:17Z")

</div>

Hey,  
So I know that in the forum there is a click counter for every post’s link.  
Is there a way to see the **total number** of clicks for the **whole** forum? (Other than going manually through each and every post and counting them).

Thanks!

---

<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: [March 26, 2015, 9:55pm UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846/2 "2015-03-26T21:55:49Z")

</div>

There’s the “Last 30 days” at  
Admin → Dashboard  
 ![](https://global.discourse-cdn.com/meta/original/3X/0/b/0b802d36cb67a2425cb822a8f84e20b6b3c98fa6.png)

---

<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: [March 27, 2015, 12:03am UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846/3 "2015-03-27T00:03:48Z")

</div>

That’s not quite the same thing, I think Tiffany is asking about _outgoing_ clicks. Those are incoming links.

We don’t have a global “most clicked link across all topics on the site”, but the data is present in the database and would probably be easy enough to query out.

---

<div class="post-metadata">

### Author: ![Tiffany\_Stelman](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@Tiffany\_Stelman](https://meta.discourse.org/u/Tiffany_Stelman)
#### Post date: [March 27, 2015, 2:52pm UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846/4 "2015-03-27T14:52:18Z")

</div>

Thank you Jeff, this is exactly what I meant.

Is there a place where I can see how to find/ query this data in the database?

---

<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: [March 27, 2015, 4:49pm UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846/5 "2015-03-27T16:49:14Z")

</div>

I believe what you’re interested in is the topic\_links table (in /db/structure.sql)

```plaintext
CREATE TABLE topic_links (
    id integer NOT NULL,
    topic_id integer NOT NULL,
    post_id integer,
    user_id integer NOT NULL,
    url character varying(500) NOT NULL,
    domain character varying(100) NOT NULL,
    internal boolean DEFAULT false NOT NULL,
    link_topic_id integer,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    reflection boolean DEFAULT false,
    clicks integer DEFAULT 0 NOT NULL,
    link_post_id integer,
    title character varying(255),
    crawled_at timestamp without time zone,
    quote boolean DEFAULT false NOT NULL
);

```

In the Rails console you could do something like  
`TopicLink.order("clicks DESC").limit(1)`  
which gives this from my localhost Discourse

```plaintext
=> [#<TopicLink id: 2, topic_id: 18, post_id: 18, user_id: 2, url: "/faq", domai
n: "localhost:4000", internal: true, link_topic_id: nil, created_at: "2013-01-29
 05:25:59", updated_at: "2013-01-29 05:25:59", reflection: false, clicks: 1, lin
k_post_id: nil, title: nil, crawled_at: nil, quote: false>]

```

---

<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: [March 27, 2015, 7:07pm UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846/6 "2015-03-27T19:07:57Z")

</div>

Ah, notice in the previous `internal: true` that should be in the query for false.

I did some testing on my localhost Discourse and got this from the same query as previous so this is the table you want

```plaintext
=> [#<TopicLink id: 80, topic_id: 86, post_id: 128, user_id: 27, url: "http://co
mmunity.sitepoint.com/", domain: "community.sitepoint.com", internal: false, lin
k_topic_id: nil, created_at: "2015-03-27 18:14:34", updated_at: "2015-03-27 18:1
4:34", reflection: false, clicks: 4, link_post_id: nil, title: nil, crawled_at:
nil, quote: false>]

```

---

<div class="post-metadata">

### Author: ![Tiffany\_Stelman](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@Tiffany\_Stelman](https://meta.discourse.org/u/Tiffany_Stelman)
#### Post date: [March 27, 2015, 7:20pm UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846/7 "2015-03-27T19:20:21Z")

</div>

I will try that, thank you so much!!

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [December 4, 2025, 11:35am UTC](https://meta.discourse.org/t/aggregated-click-number-on-forum-click-counter/26846/8 "2025-12-04T11:35:47Z")

</div>


