Adding the Google Analytics (or any analytics script really) to a Stackbit site - Gatsby or not - is easy and doesn't require that you edit any code at all. Instead, we'll use a feature in Netlify called snippet injection. Here are the steps:
Get the Google Analytics code for your site from Google
In your site's Netlify dashboard, go to Settings > Build & Deploy > Post Processing and click the "Add Snippet" button.
</head>", which is where Google suggests you place analytics code and then paste your analytics snippet into the provided text box. Hit save.
Your site will now automatically have the analytics code injected on every page.