Skip to content

Google Analytics 4

Terminal window
npm install @junctionjs/destination-ga4
import { createCollector } from "@junctionjs/core";
import { ga4 } from "@junctionjs/destination-ga4";
const collector = createCollector({
destinations: [
{
destination: ga4,
config: {
measurementId: "G-XXXXXXXXXX",
consentMode: true,
},
},
],
});
  • gtag.js — automatically loads the gtag snippet on the client (configurable)
  • Measurement Protocol — server-side sending via GA4’s HTTP API
  • Consent Mode v2 — native integration with Google’s consent signals
  • Recommended events — default mapping for GA4’s recommended event names
  • Event name overrides — customize any mapping via eventNameMap
  • Custom script URL — self-host or proxy the gtag.js script
Junction EventGA4 Event
page:viewedpage_view
product:viewedview_item
product:addedadd_to_cart
order:completedpurchase