Gatsby Google Analytics

Gatsby Google Analytics

by John Vincent


Posted on September 20, 2019


Configuring Google Analytics with Gatsby is straightforward.

Gatsby Google Analytics Plugin

Using the plugin gatsby-plugin-google-analytics, add to gatsby-config.js

{
	resolve: `gatsby-plugin-google-analytics`,
	options: {
		trackingId: `UA-102737102-1`,
		head: false,
		exclude: [`/private/**`],
		cookieDomain: `${domain}`,
	},
},

where domain = johnvincent.io

This plugin is only executed for production builds.