# Search Logs Page

**URL:** https://meta.discourse.org/t/search-logs-page/73281
**Category:** Announcements
**Created:** [November 2, 2017, 12:48pm UTC](https://meta.discourse.org/t/search-logs-page/73281 "2017-11-02T12:48:03Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [November 2, 2017, 12:48pm UTC](https://meta.discourse.org/t/search-logs-page/73281/1 "2017-11-02T12:48:03Z")

</div>

Now that we have [search logging](https://meta.discourse.org/t/effectively-logging-search-queries/63838) in place it’s time to put that data into action.

I propose creating a new page under “Admin” → “Logs” → “Search Logs” tab, like so:

 ![39](https://global.discourse-cdn.com/meta/original/3X/a/7/a7e5a24f59aff01b581c677b20ca0c3c7ddeb5d5.png)

The initial version of search logs page will contain following data points:

- `term`: the search term.

- `searches`: number of times the term has been searched for.

- `continued from search`: number of times user has clicked on topic from search results.

- `most viewed topic`: the topic that has been visited most for a particular term.

- `unique`: number of unique searches (from different ip addresses) performed for a term.

Following filters will be available in initial version:

- `start date`

- `end date`

Improvements to consider in future:

- `term` filter to fetch search log data for a particular term
- `topic id` filter to fetch search log data for a particular topic
- how to handle multi-word search term like “wordpress sso”

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [November 2, 2017, 1:08pm UTC](https://meta.discourse.org/t/search-logs-page/73281/3 "2017-11-02T13:08:06Z")

</div>

Nice work. For site admins very useful to know what users want. 👍

In future if we had an option to add tags automatically based on `continued from search` threshold then it will become great.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [November 2, 2017, 2:08pm UTC](https://meta.discourse.org/t/search-logs-page/73281/4 "2017-11-02T14:08:18Z")

</div>

> [@techAPJ](#):
>
> continued from search

“Click through” is the term that SEO wizards use.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [November 2, 2017, 7:29pm UTC](https://meta.discourse.org/t/search-logs-page/73281/5 "2017-11-02T19:29:56Z")

</div>

> [@techAPJ](#):
>
> Following filters will be available in initial version:
> 
> start date
> 
> end date

Could we also get a simple Top style timespan-dropdown there?

 ![58](https://global.discourse-cdn.com/meta/original/3X/d/1/d1fad12cb710637fa94e660253f4779b608d7b6b.png)

Would like a simple way to check for current trends.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 3, 2017, 4:28am UTC](https://meta.discourse.org/t/search-logs-page/73281/6 "2017-11-03T04:28:34Z")

</div>

Looks good to me, many people have asked for it, will be awesome to have it in the product.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [November 14, 2017, 1:17pm UTC](https://meta.discourse.org/t/search-logs-page/73281/9 "2017-11-14T13:17:23Z")

</div>

Here is a PR for this feature:

[https://github.com/discourse/discourse/pull/5313](https://github.com/discourse/discourse/pull/5313)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [November 15, 2017, 7:04am UTC](https://meta.discourse.org/t/search-logs-page/73281/10 "2017-11-15T07:04:05Z")

</div>

@sam merged the PR. The new search logs/trends page is now live at **`/admin/logs/search_logs`**. 🔎

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 15, 2017, 7:19am UTC](https://meta.discourse.org/t/search-logs-page/73281/11 "2017-11-15T07:19:38Z")

</div>

Looks good but I think we need some refinements:

1. [✅] We need to be tracking click through to user, tag and category. If you click through to any of those the search is still a success, we now only track click through to topic AFAIK.

2. [✅] We should log fullpage vs mini search in the table (then we can add a “all” / “header” / “fullpage” filter to this page)

3. [✅] Left align search terms, left align most viewed topic

4. It would be nice to be able to click through to the actual search, but its a tricky UI change cause you don’t really want to make all the terms blue and you don’t want to add an icon that repeats 100 time

5. [✅] We should sort by unique descending, not by searches

6. [✅] Add tooltip on unique: “unique users performing the search”

7. We should think about ways of allowing people to track “progress” here, for example:

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [November 15, 2017, 1:56pm UTC](https://meta.discourse.org/t/search-logs-page/73281/13 "2017-11-15T13:56:01Z")

</div>

> [@sam](#):
>
> We should sort by unique descending, not by searches

@techAPJ how much feature creep would it be to allow user sorting like `/u`?

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [November 15, 2017, 6:20pm UTC](https://meta.discourse.org/t/search-logs-page/73281/14 "2017-11-15T18:20:23Z")

</div>

Not much, but I feel like it’s unnecessary at this point. I can add it on my low-priority list.

---

<div class="post-metadata">

### Author: ![nixie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nixie/32/82174_2.png) [@nixie](https://meta.discourse.org/u/nixie)
#### Post date: [November 15, 2017, 10:41pm UTC](https://meta.discourse.org/t/search-logs-page/73281/15 "2017-11-15T22:41:53Z")

</div>

@techAPJ

“Click through to a topic” doesn’t look like getting tracked properly.

This is what I did

1. Searched for a term. Clicked on a topic and scrolled till the bottom of the page.
2. Accessed /admin/logs/search\_logs?period=daily
3. I can see the term that I searched for. But it shows “0” on “click through count”, “most viewed topic” column is also blank.

I thought something is wrong with “click through tracking to topics” because, when I checked “today’s search logs”, I can see like 100+ searches, but “click through count” and “most viewed topic” column is filled for just 2 search terms. This is when I did a search myself to confirm if something is really wrong. And after my tests “like I mentioned above”, it looks like its not tracking “click through to topics” correctly.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [November 30, 2017, 12:33pm UTC](https://meta.discourse.org/t/search-logs-page/73281/16 "2017-11-30T12:33:54Z")

</div>

> [@sam](#):
>
> We need to be tracking click through to user, tag and category. If you click through to any of those the search is still a success, we now only track click through to topic AFAIK.

> [@sam](#):
>
> We should log fullpage vs mini search in the table (then we can add a “all” / “header” / “fullpage” filter to this page)

PR for review here:

[https://github.com/discourse/discourse/pull/5385/](https://github.com/discourse/discourse/pull/5385/)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [November 30, 2017, 12:36pm UTC](https://meta.discourse.org/t/search-logs-page/73281/17 "2017-11-30T12:36:00Z")

</div>

> [@sam](#):
>
> We need to be tracking click through to user, tag and category.

I noticed that currently we are tracking clicks only from header search, and not from full page search. Is this intentional? (cc @eviltrout)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [November 30, 2017, 5:50pm UTC](https://meta.discourse.org/t/search-logs-page/73281/18 "2017-11-30T17:50:50Z")

</div>

It should be tracked in both places. I just never got around to the second page.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [December 1, 2017, 5:58pm UTC](https://meta.discourse.org/t/search-logs-page/73281/19 "2017-12-01T17:58:15Z")

</div>

Okay, we’ll now track clicks on full page search as per:

[https://github.com/discourse/discourse/commit/54f5b4d4e066bb3457d7e91619737611e09cd640](https://github.com/discourse/discourse/commit/54f5b4d4e066bb3457d7e91619737611e09cd640)

> [@nixie](#):
>
> “Click through to a topic” doesn’t look like getting tracked properly.

Were you by any chance performing “full page” search? If yes, please update to latest version and test again, it should be fixed now.

---

<div class="post-metadata">

### Author: ![nixie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nixie/32/82174_2.png) [@nixie](https://meta.discourse.org/u/nixie)
#### Post date: [December 1, 2017, 5:59pm UTC](https://meta.discourse.org/t/search-logs-page/73281/20 "2017-12-01T17:59:29Z")

</div>

Awesome I’ll check and let you know..

---

<div class="post-metadata">

### Author: ![nixie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nixie/32/82174_2.png) [@nixie](https://meta.discourse.org/u/nixie)
#### Post date: [December 5, 2017, 2:49am UTC](https://meta.discourse.org/t/search-logs-page/73281/21 "2017-12-05T02:49:14Z")

</div>

@techAPJ  
Yes it works now.

Is it possible to add an export to csv feature?

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [December 5, 2017, 5:58pm UTC](https://meta.discourse.org/t/search-logs-page/73281/22 "2017-12-05T17:58:21Z")

</div>

> [@sam](#):
>
> We should think about ways of allowing people to track “progress” here

Here’s what I am thinking. Please let me know your opinion.

If an Admin wants to drill into the term, they will click on the term and go to term details page, which will look like:

 ![SSO](https://global.discourse-cdn.com/meta/original/4X/3/e/f/3ef72f308ab4ca52a92f6e9f6bef183b6aab6d87.png)

- Clicking on the term “sso” again, admin will go to full page search with “sso” prefilled.

- There will be a search type (header/fullpage) filter.

- Admin will be able to see the stats/trends for different time periods (similar to what they see on dashboard) for that term on one page.

Does the above looks good?

---

<div class="post-metadata">

### Author: ![alxpck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alxpck/32/243713_2.png) [@alxpck](https://meta.discourse.org/u/alxpck)
#### Post date: [April 10, 2018, 3:37pm UTC](https://meta.discourse.org/t/search-logs-page/73281/23 "2018-04-10T15:37:30Z")

</div>

Does `unique` track IP addresses or user accounts? (since users may use more than one IP)

It sounds like IP addresses here:

> [@techAPJ](#):
>
> unique: number of unique searches (from different ip addresses) performed for a term.

And user accounts here:

> [@sam](#):
>
> Add tooltip on unique: “unique users performing the search”

Our sites are only visible to people with user accounts, and that’s not the case for everyone so _probably_ it’s IP addresses, but maybe there’s some magic going on in the background. Either way, it would be useful for us to know which of the two it is.

Sorry if this is too pedantic.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 11, 2018, 4:46am UTC](https://meta.discourse.org/t/search-logs-page/73281/24 "2018-04-11T04:46:31Z")

</div>

@techAPJ can confirm but in your case (“a requires login community”) the unique count is the unique count of users. AFAIK we use user\_id and then fallback to ip

[Next page](https://meta.discourse.org/t/search-logs-page/73281.md?page=2)
