Tracking of Pageviews and Unique Users at Category and Tag Level

I am curious if you have advice on tracking community health metrics at the category and/or tag level.
For example, I’d love to have a clearer sense of the daily number of pageviews and user visits (both known and anonymous users, and ideally by specific group-members) on topic-threads under each category and tag.

In /admin/dashboard/reports, new topics and new post have reports that can be filtered to the category level, user profile_views can be filtered by group, and there are sitewide metrics on page views and other useful info.

I suspect some of this can be set-up somehow in Google Analytics, but that’s not obvious to me since it’s not obvious how to associate topic urls with tags and categories in google analytics. I also suspect this may be done via the /admin/plugins/explorer, but I haven’t had any success.

Your advice would be greatly appreciated.

Do you have any advice here @hawk? It seems like a reasonable question and maybe new dashboard / reports covers this a bit?

It does seem like a reasonable request, yes. At the moment the reports on the dashboard aren’t segment-able but if we can work out a way to do that I think it would be an excellent addition to v2. We’ve also talked about exposing approved Data Explorer queries on the dashboard.

cc @j.jaffeux – do you have plans to revisit the dashboard any time soon?

Yes, it will be step by step but might come to something close to this. I don‘t want it to become too complex though and it will never be a “combine any segment you want”, there’s sql (and data-explorer) for this. But will probably try to provide this on a per report basis where we think it makes sense.

This query is specifically about pageviews per category, which I don’t think can be handled with Data Explorer can they?

Yes, I would also be interested in a report about the unique users on my site.

Yes this specific report is using ApplicationRequest table, which doesn’t have any notion of category. So not possible through reports, data-explorer or raw sql.

Can we pull a report on the number of anonymous users instead of the number of pages viewed anonymously?

Do you mean the number of people that have used the anonymous posting feature? They all get unique anonymous usernames so it will be very easy to pull a report from Data Explorer

I’m trying to find out how many people are visiting the site who have not logged in at all and do not have an account.

이것도 보고 싶어요! 쿼리를 구성하는 방법에 대한 조언이 있을까요? 감사합니다!

우리는 또한 이 숫자(크롤러 활동 제외, 카테고리별 PV)를 원합니다. Data Explorer에서 이를 가져올 수 있는 방법이 있나요?

그렇지 않을 것 같습니다. 우리는 그렇게 세밀하게 페이지 뷰를 추적하지 않습니다. GA를 연결해서 사용해야 합니다.

@HAWK: 그러면 이건 불가능할 것 같나요? Counting Pageviews for users (non-staff, non-crawler)

특정 카테고리 내 모든 게시물의 페이지 뷰를 집계하는 해결책을 찾으신 분이 계신가요? GA로 가능한가요?

Data Explorer에서 카테고리 하위 모든 토픽의 조회수를 합산하여 카테고리 전체 조회수를 확인할 수 있습니다:

SELECT 
       c.id as category_id, 
       SUM(views) as "total views"
FROM categories c 
JOIN topics t ON t.category_id = c.id
WHERE read_restricted is false
GROUP BY c.id
order by sum(views) desc

태그별 전체 조회수를 가져오는 방법도 비슷합니다:

SELECT tags.name,
       sum(views)
from topics t
     join topic_tags tt on t.id = topic_id
     join tags on tags.id = tt.tag_id
group by tags.name
order by sum(views) desc

이론적으로 사용자와 날짜별로 조회수를 나눌 수 있는 topic_views 테이블도 있습니다. 하지만 토픽의 조회수가 많으면 쿼리가 타임아웃이 발생하여 이 테이블은 특별히 유용하지 않다는 것을 발견했습니다. 또한, 제 이해가 맞다면 익명 조회수를 집계하지 않기 때문에 토픽당 조회수가 훨씬 적게 표시됩니다. topic.views에는 익명 조회수뿐만 아니라 봇 트래픽도 포함된 것 같습니다. GA에서 보는 수치보다 훨씬 많습니다.

GA에 대해 말하자면, 필요한 모든 데이터가 있지만 카테고리나 태그별로 그룹화하기가 쉽지 않습니다. 제가 할 수 있는 최선은 pageTitle을 파싱하여 카테고리를 찾는 것입니다. 저는 R을 사용하여 googleAnalyticsR 패키지로 이를 수행하고 있습니다. 매뉴얼의 지침에 따라 Google 계정을 인증하고 원하는 지표를 가져오세요. pageTitle을 차원(dimension)으로 포함하는 것을 잊지 마세요. 제 API 호출은 다음과 유사합니다:

ga_this_year <- ga_data(ga_id, 
                        date_range = c("2023-01-01", "2023-05-30" ),
                        metrics=c("screenPageViews","averageSessionDuration", "sessions"), 
                        dimensions = c("pageTitle", "deviceCategory")
                       )

다음 부분을 이해하는 핵심은 pageTitle이 다음과 같은 일반적인 형식을 따른다는 것입니다:

토픽 제목 - 카테고리 - 사이트 제목

토픽에 카테고리가 없으면 Category 부분이 누락됩니다. 또한 카테고리가 없는 유틸리티 페이지(“Latest topics”, “New topics” 등)도 여러 개 있습니다. ("Latest [category] topics"는 카테고리 일부로 집계하지 않지만, 포함하는 것이 더 나을 수도 있습니다.) 마지막으로 홈페이지는 페이지 제목으로 사이트 제목 - 짧은 사이트 설명을 사용합니다. 하지만 우리는 이들에 대해 신경 쓸 필요가 없습니다. 따라서 제가 사용하는 정규식은 다음과 같습니다:

str_extract(pageTitle,
            str_glue(".*? - (.*) - {sitename}"),
            group=1)

카테고리로 그룹화하는 함수로 이를 조합하면 다음과 같은 결과가 나옵니다:

category_views <- function(data, sitename = "Meta Jon") {
  data %>% 
  mutate(category = str_extract(
                                pageTitle,
                                str_glue(".*? - (.*) - {sitename}"),
                                group=1
                                )) %>% 
  group_by(category) %>% 
  summarise(views = sum(screenPageViews)) %>% 
  arrange(desc(views)) #%>% head(20)
}

category_views(ga_this_year)

(물론 "Meta Jon"은 자신의 사이트 이름으로 변경해야 합니다.)

다만, 현재 태그를 기준으로 GA 데이터를 추출하는 방법은 모릅니다.

그 총 조회수는 봇, 즉 익명 사용자도 포함합니까?

GA는 공식 문서에 따르면 봇 트래픽을 제외합니다. topic_views에 대한 문서는 찾지 못했지만, 코드 내의 주석에는 다음과 같이 나와 있습니다:

# Only store a view once per day per thing per (user || ip)

확실하지는 않지만, topic.views는 동일한 페이지에 대해 GA보다 훨씬 많은 조회 수를 표시하기 때문에 봇의 페이지 조회를 포함하고 있는 것으로 보입니다.

네, 하지만 데이터 익스플로러를 사용할 때 디스커스의 카운트는 어떻게 되나요?

이전에 GA도 같은 내용을 알려주었고, 합법적인 봇이 존재할 경우 이는 사실일 수 있습니다. 하지만 대부분의 호출은 불법적인 봇, 행실이 나쁜 SEO 봇, 크리커(knckers) 등에 의해 발생하며, 이 경우 1회 방문 규칙이 깨지게 됩니다. 솔직히 말하면, 그렇게 생각할 뿐입니다.

어쨌든, 저는 Matomo를 사용 중입니다. GA가 필요한 만큼 큰 규모는 아니기 때문입니다.

참고로, 이는 실제로 topic_views 테이블이 하루에 1회로 뷰 계산을 제한하기 때문이며, topics.views 필드는 (기본값이지만 topic view duration hours를 사용하여 변경 가능) 8시간마다 1회의 새 뷰를 허용하도록 집계합니다. 이 필드는 사용자 및 anon 모두를 포함합니다. :+1:

업데이트

결국 topic_views 테이블은 하루에 1회의 새 뷰를 집계하는 것조차 아닙니다. 실제로는 누군가가 주제를 처음 본 시점만 집계하고, 그 이후의 뷰는 더 이상 집계하지 않습니다. 따라서 사용자 또는 IP당 주제별 레코드는 항상 1개만 생성됩니다.