Skip to content
Blog Home
Articles
Category
  • Blog Home
    • Slide page
      • Articles

          • Stopping specific bots from using your monthly ShipperHQ quota
            • Dockerizing a MERN stack
              • Easy way to add google Ads to vuepress running on netlify
                • Easy way to add google analytics to vuepress running on netlify

              Easy way to add google Ads to vuepress running on netlify

              author iconMichael LaPancalendar iconApril 6, 2022category icon
              • Programming
              tag icon
              • programming
              • netlify
              • vuepress
              timer iconLess than 1 minute

              # Easy way to add google Ads to vuepress running on netlify

              This is the same way to add google analytics

              Go to your site -> Site settings -> Build & deploy -> Post processing -> Snippet injection

              Click the drop down -> hit before body.

              To save you some time here is the code I use to dynamically inject the ads.

              This script will include the google ad scripts. wait 800 ms and add the google ad block to your sidebar. wait 1.5 sec to start serving ads.

              These times could be shortened, but i put them this way to ensure the page is fully loaded.

              <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=YOUR-AD-ID"
                   crossorigin="anonymous"></script>
              
              <script>
               setTimeout(() => {
              document.querySelector(".sidebar-links").appendChild(document.createElement("div")).innerHTML = '<ins class="adsbygoogle" style="display:block" data-ad-client="YOUR-AD-ID" data-ad-slot="1001042129" data-ad-format="auto" data-full-width-responsive="true"></ins>'
              }, 800);
              
              </script>
              <script>
               setTimeout(() => {
              (adsbygoogle = window.adsbygoogle || []).push({});
              }, 1500);
                   
              </script>
              
              1
              2
              3
              4
              5
              6
              7
              8
              9
              10
              11
              12
              13
              14
              15
              Last update: 4/7/2022, 1:13:25 AM
              Contributors: Michael lapan
              Prev
              Dockerizing a MERN stack
              Next
              Easy way to add google analytics to vuepress running on netlify
              Copyright © 2022 Michael LaPan

              This app can be installed on your PC or mobile device. This will allow this web app to look and behave like any other installed app. You will find it in your app lists and be able to pin it to your home screen, start menus or task bars. This installed web app will also be able to safely interact with other apps and your operating system.

              Description