In order to inject AdSense snippet into your Gatsby/React app which is deployed using Netlify follow the below process.
-
Login to your Netlify account here's what it looks like: Select the site where you want to inject AdSense. In my case, I'd like to inject into the site
www.pratapsharma.io
. -
Click on
Site Settings
-> and then onBuild and Deploy
(in the left pane) -
Scroll down and find
Post-processing
->Snippet Injection
and then add on click snippet.
![SnippetInjection](../screenshots/Screen-shot-2020-04-16 at 3.02.49 PM.png "Snippet Injection")
- Select the tag from dropdown where you want to insert the script. In our case we'll select
Insert before </head>
. Then give the nameAdSense
(you can give any name you like). Finally, paste the link HTML script which you get fromGoogle Adsense
inHTML text field
. Click on Save.
The process of adding AdSense snippet usually takes a few days, but in some cases, it can take up to 2 weeks. Google will notify you when everything's ready.
You've successfully injected Google Adsense into Gatsby/React app.
This has worked great for me, and I personally really like this feature. Especially, for site generator like Gatsby which doesn't include a default index.html file where you can include your scripts.
💌 If you’d like to receive more tutorials in your inbox, you can sign up for the newsletter here.
Discussions