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