// gatsby-ssr.js (or gatsby-ssr.tsx) // statpx Analytics — Gatsby SSR integration // Place this file in your Gatsby project root // Replace YOUR_TRACKING_ID with your ID from statpx.com → Dashboard → Snippet const React = require('react') exports.onRenderBody = ({ setPostBodyComponents }) => { setPostBodyComponents([ React.createElement('script', { key: 'statpx-config', dangerouslySetInnerHTML: { __html: "window._stid='YOUR_TRACKING_ID';window._stendpoint='https://statpx.com';" }, }), React.createElement('script', { key: 'statpx-track', src: 'https://statpx.com/track.js', async: true, }), ]) } // ─── gatsby-browser.js (optional — SPA route tracking) ──────────────────── // statpx track.js intercepts history.pushState automatically. // No extra configuration needed for SPA navigation tracking.