vincentdnl.com

Hi 👋, I'm Vincent Déniel. I'm a developer and also an entrepreneur on my free time. I draw cartoons about software development.

Add a Gatsby site to the Google Search Console with Google Analytics

June 28, 2019#GatsbyJS, #SEO

There are several methods to add a website to the Google Search Console and claim its ownership. If you are using GatsbyJS for your static site, you might already be using the gatsby-plugin-google-analytics plugin. It is installed by default on the most popular blog starter.

This is the default configuration in the gatsby-config.js file:

{
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId: `<trackingId>`
}
}

When you go on the Google Search Console to add a new property and click on “Alternate Method” for validation, you have the “Google Analytics”. Clicking on it will result in an error telling you that the javascript analytics javascript must be placed in the header of the site.

Just add head: true to the configuration:

{
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId: `<trackingId>`,
head: true
}
}

Now you might want to associate your Analytics and Search Console properties for additional information in Analytics.

I hope this simple tip saved you some time!

Hey 👋! If you enjoy this article, please consider buying me a coffee!

Buy Me A Coffee