Add Google Adsense to your Gatsby site.
npm install --save gatsby-plugin-google-adsense
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-google-adsense`,
options: {
googleAdClientId: "YOUR_GOOGLE_ADSENSE_TRACKING_ID",
head: false // Optional
}
}
]
};
Here you place your Google Adsense tracking id.
Here you can define where to place the tracking script. With head:true
it will placed in the header, with head:false
it will placed in the body. Defaults to false
.