Friday, 30 December 2016

How to Monetize Google Maps on your Website with AdSense Ads

You have been using Google AdSense ads to monetize the content of your website but did you know that you can also use the same AdSense program to also monetize any Google Maps that are embedded on your web pages. You can embed a Google Map and AdSense ads will be automatically served inside the map that will either be contextually relevant to the content of the page or targeted based on the location of the visitors.

The Google Maps block embedded below contains a rectangular AdSense ad unit placed near the top-center area of the map. Where Am I is another example of a website that embeds Google Maps with ads.



AdSense Ads for Embedded Google Maps

Google Maps offers you an easy option to embed maps onto your website but the default embed code does not allow monetization. You’ll have build the map on your own using the Google Maps API to enable advertising and this isn’t difficult either. Let me show you in few easy step.

To get started, go to the Google AdSense website and create a new ad unit. You can choose the default color scheme for the ad unit (white background) and pick responsive for the size. The latter doesn’t matter though as the ad unit will automatically fit inside the container map.

Next, copy-paste the following Google Maps embed code anywhere in your web template.

<div id="google-maps" style="width:500px; height:500px;"></div>

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp">
 </script>
<script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
 </script>

<script>

  function showGoogleMaps() {

    var mapOptions = {
      center: new google.maps.LatLng(38.8977, -77.036),
      zoom: 5
    };

    var map = new google.maps.Map(
      document.getElementById('google-maps'), mapOptions);

    var ad = '<ins class="adsbygoogle" \
              style="display:inline-block;width:300px;height:100px" \
              data-ad-client="ca-pub-xxxx" \
              data-ad-slot="yyyy"></ins>';

    var adNode = document.createElement('div');
    adNode.innerHTML = ad;

    map.controls[google.maps.ControlPosition.TOP_CENTER].push(adNode);

    google.maps.event.addListenerOnce(map, 'tilesloaded', function() {
      (adsbygoogle = window.adsbygoogle || []).push({});
    });

  }

  google.maps.event.addDomListener(window, 'load', showGoogleMaps);

</script>

You can replace the height and width of the Google Maps in line #1 to fit your website layout while the latitude and longitude of the place needs to be replaced in line #11. Finally, xxxx and yyyy in the embed code should be replaced with your AdSense Publisher ID and the Ad Slot ID respectively. You can find these values in the embed code generated by AdSense.

5 comments:

  1. The best website builder to pick will rely upon whether you are actually best in class or a learner with regards to PCs. find more info

    ReplyDelete
  2. Website manufacturers have a rundown of topics that you can browse and a decent one should enable you to roll out improvements wherever you need and wishEdknt Media

    ReplyDelete
  3. An outstanding share! I've just forwarded this onto a co-worker who was doing a little homework on this. And he actually bought me dinner due to the fact that I stumbled upon it for him... lol. So allow me to reword this.... Thanks for the meal!! But yeah, thanx for spending the time to talk about this subject here on your web site. apple itunes login

    ReplyDelete

  4. MovieBox App is an excellent app for everyone who loves to watch Online movies, songs, TV shows etc on your SmartPhone. In this app, you can find the list of latest movies and TV shows as the MovieBox database is frequently updated.

    ReplyDelete