Add Google Analytics into Gatsby Website

1. Install gatsby-plugin-google-analytics

gatsbyGoogleAnalytics

2. Add gatsby plugin in gatsby-config.js

module.exports = {  siteMetadata: {    title: '<CodeWithMe />',    author: 'Özge Karaoğlu'  },  plugins: [    {      resolve: 'gatsby-plugin-google-analytics',      options: {        trackingId: process.env.GOOGLE_ANALYTICS_TRACKING_ID || "none"      }    }

gatsbyplugin

3. Add New Environmental Variable

Open your Netlify Account

Select Build & Deploy

environmentalVariable

Click Edit Variables

Create new one

Save

April 11th, 2020

Created by Özge Karaoğlu, 2020