Is there a way to filter statistics by the country? Does anyone have a Plugin for this perhaps?
I’m getting inquiries from all around the world and would like to know which country was the moste active every month.
Thanks ![]()
AI-generated summary
Users are discussing how to filter Discourse statistics by country, as this feature isn’t natively available. warri0r asks if a plugin exists to track country-based activity, especially for monthly insights. RBoy confirms no built-in solution exists yet and suggests using Google Analytics (GA) as a workaround, while expressing hope for native integration. j127 shares custom JavaScript code they added to their theme to send events (like topic/post creation) to GA4 and other analytics platforms, noting it’s messy but functional. ToddZ recommends OpenPanel as a privacy-friendly, self-hostable or low-cost hosted alternative to GA, including screenshots of its interface. RBoy questions whether simply adding a GA ID in Discourse settings should automatically enable full analytics, wondering if they’re missing something. j127 clarifies they manually load GA, possibly because the built-in feature didn’t exist when they set up their site, and they’re currently sending data to three analytics services. The discussion highlights community interest in country-level analytics and workarounds using third-party tools or custom code.
I don’t that exists as yet, traffic by country. It’s been requested a few times but the the answer appears to be use google analytics.
It would be awesome to that feature built directly in discourse through, one stop shop ![]()
I wrote some code in my theme to send events into GA4 (and two other services) that can be filtered by country.
I can post the full file, if anyone wants to drop it in your theme, but it’s kind of messy. Here’s a sample:
api.onAppEvent("topic:created", (post, composerModel) => {
if (post) {
sendPHogEvent("topic_created", {});
sendClickyEvent("#topic_created", "topic_created", "click");
sendGA4Event({
action: "topic_created",
});
}
});
api.onAppEvent("post:created", (post) => {
if (post) {
sendPHogEvent("post_created", {});
sendClickyEvent("#post_created", "post_created", "click");
sendGA4Event({
action: "post_created",
});
}
});
Since I don’t want Google tracking and GDPR questions, I’m currently using https://openpanel.dev/ – it’s pretty nice. Open source & self-hostable, or hosted starting at $2.50/mo.
Interesting. I thought that by adding the GA ID in the discourse settings it would automatically send everything required for GA do all the analytics. Isn’t that the purpose of GA analytics or am I missing something here?
I’m not sure. I just checked and I think I’m manually loading GA. Maybe that feature didn’t exist when I built the site and I missed it?
In any case, I’m sending events into three kinds of analytics.

