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.

4 Mi Piace

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

2 Mi Piace

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?

6 Mi Piace

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.

4 Mi Piace

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

2 Mi Piace

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.

2 Mi Piace

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

1 Mi Piace

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

2 Mi Piace

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.

2 Mi Piace

Would love to see this as well! Any advice on how to construct a query? Thx!

We also want this number (PVs per category, excluding crawler activity). Is there a way to get this from the Data Explorer?

I don’t believe so. We don’t granularly track page views like that. You would need to hook up your GA and use that.

1 Mi Piace

@HAWK: Do you reckon this won’t be possible then? Counting Pageviews for users (non-staff, non-crawler)

Has anyone found a solution to count page views for all posts within a specific category? Possible with GA?

1 Mi Piace

È possibile ottenere le visualizzazioni totali per categoria da Data Explorer sommando le visualizzazioni di tutti gli argomenti di una categoria:

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

Ottenere le visualizzazioni totali per tag è simile:

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

Esiste anche una tabella topic_views che potrebbe, in teoria, essere utilizzata per dividere le visualizzazioni per utente e data. Tuttavia, non ho trovato quella tabella particolarmente utile, poiché le query vanno in timeout quando gli argomenti hanno molte visualizzazioni. Mostra anche molte meno visualizzazioni per argomento perché, se ho capito bene, non conta le visualizzazioni anonime. Penso anche che topic.views includa non solo le visualizzazioni anonime ma anche il traffico dei bot? È molto di più di quello che vedo su GA.

Parlando di GA, contiene tutti i dati di cui hai bisogno, ma non è facile raggrupparli per categoria o tag. Il massimo che posso fare è provare a fare il parsing di pageTitle per trovare le categorie. Lo sto facendo in R usando googleAnalyticsR. Segui le istruzioni nel manuale per autorizzare il tuo account Google e ottenere le metriche desiderate. Assicurati di includere pageTitle come dimensione. Le mie chiamate API sono un po’ così:

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")
                       )

La chiave per capire il passaggio successivo è vedere che i pageTitles seguono questo formato generale:

Titolo argomento - Categoria - Titolo sito

Se l’argomento non è categorizzato, la Categoria è mancante. Ci sono anche molte pagine di utilità (“Ultimi argomenti”, “Nuovi argomenti”, ecc.) che non hanno categorie. (Non sto contando “Ultimi argomenti [categoria]” come parte della categoria, anche se potrebbe essere meglio includerli.) Infine, la homepage usa Titolo sito - breve descrizione sito per il titolo della pagina. Tuttavia, non ci interessa nessuno di questi. Quindi, la regex che sto usando è:

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

Mettendo tutto insieme in una funzione che raggruppa per categoria, ottengo qualcosa di simile:

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)

(Ovviamente cambia “Meta Jon” con il nome del tuo sito.)

Attualmente non so come estrarre i dati GA in base al tag.

2 Mi Piace

Quelle visualizzazioni totali includono anche i bot, alias anonimi?

GA esclude il traffico dei bot, secondo la loro documentazione. Non riesco a trovare la documentazione per topic_views, ma un commento nel codice dice:

# Memorizza una visualizzazione solo una volta al giorno per cosa per (utente || ip)

Non lo so per certo, ma topic.views sembra mostrare le visualizzazioni di pagina dei bot perché mostra molte più visualizzazioni rispetto a quelle che GA mostra per la stessa pagina.

Sì, ma i conteggi di Discourse quando si utilizza Data Explorer?

In precedenza, GA ha detto lo stesso e potrebbe essere vero quando ci sono bot legittimi. Ma la maggior parte delle chiamate avviene da parte di bot malintenzionati, bot SEO con comportamenti scorretti, knocker, ecc. e quindi la regola di una visita viene infranta. O almeno così credo, ad essere onesti.

Comunque, uso Matomo. Non sono un pesce così grosso da aver bisogno di GA.

Solo per tua informazione, questo accade in realtà perché la tabella topic_views limita il conteggio a una nuova visualizzazione al giorno, mentre il campo topics.views consente una nuova visualizzazione ogni 8 ore (per impostazione predefinita, ma modificabile utilizzando topic view duration hours). Include utenti e anonimi. :+1:

AGGIORNAMENTO
Si scopre che la tabella topic_views non conta nemmeno una nuova visualizzazione al giorno… In realtà conta la prima volta che qualcuno visualizza un argomento e non più visualizzazioni dopo. Quindi ci sarà sempre solo un record per utente o IP per argomento.

2 Mi Piace