# Top traffic sources by topic

**URL:** https://meta.discourse.org/t/top-traffic-sources-by-topic/237436
**Category:** Data & reporting
**Created:** [August 29, 2022, 6:52am UTC](https://meta.discourse.org/t/top-traffic-sources-by-topic/237436 "2022-08-29T06:52:30Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![SaraDev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saradev/32/335139_2.png) [@SaraDev](https://meta.discourse.org/u/SaraDev)
#### Post date: [March 21, 2025, 7:09pm UTC](https://meta.discourse.org/t/top-traffic-sources-by-topic/237436/6 "2025-03-21T19:09:09Z")

</div>

Adding a slightly different variation of the `Topic External Traffic Sources` query above for reference here as well.

This version uses an `int_list` parameter for the `topic_ids`, so if you wanted to specify multiple `topic_ids` to run the query for, you can use this query.

```sql
-- [params]
-- int_list :topic_ids = 12345

SELECT 
  ind.name AS domain, -- External domain referring traffic
  COUNT(*) AS clicks -- Total clicks from this source
FROM incoming_links il
INNER JOIN posts p 
  ON p.deleted_at IS NULL 
  AND p.id = il.post_id
INNER JOIN topics t 
  ON t.deleted_at IS NULL 
  AND t.id = p.topic_id
INNER JOIN incoming_referers ir 
  ON ir.id = il.incoming_referer_id
INNER JOIN incoming_domains ind 
  ON ind.id = ir.incoming_domain_id
WHERE t.id IN (:topic_ids) -- Filter for the specified list of topics
  AND ind.name != '127.0.0.1'
GROUP BY ind.name
ORDER BY clicks DESC

```

---

_[View the full topic](https://meta.discourse.org/t/top-traffic-sources-by-topic/237436)._
