# Filter statistics by country

**URL:** <https://meta.discourse.org/t/filter-statistics-by-country/212427>\
**Category:** Product Support\
**Created:** [December 17, 2021, 11:36am UTC](https://meta.discourse.org/t/filter-statistics-by-country/212427 "2021-12-17T11:36:34Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)\
**Post date:** [November 6, 2025, 7:26pm UTC](https://meta.discourse.org/t/filter-statistics-by-country/212427/3 "2025-11-06T19:26:41Z")

</div>

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:

```javascript
  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",
      });
    }
  });

```

---

_[View the full topic](https://meta.discourse.org/t/filter-statistics-by-country/212427)._
