{"id":9072,"date":"2021-12-13T15:28:21","date_gmt":"2021-12-13T14:28:21","guid":{"rendered":"https:\/\/www.myagileprivacy.com\/how-to-install-google-maps-in-compliance-with-gdpr\/"},"modified":"2026-01-02T15:09:09","modified_gmt":"2026-01-02T14:09:09","slug":"how-to-install-google-maps-in-compliance-with-gdpr","status":"publish","type":"post","link":"https:\/\/www.myagileprivacy.com\/en\/how-to-install-google-maps-in-compliance-with-gdpr\/","title":{"rendered":"How to Install Google Maps in Compliance with GDPR"},"content":{"rendered":"<p>Google Maps allows you to display interactive maps directly on your website. With it, users can calculate routes, measure distances, view points of interest, addresses, and much more.<\/p>\n<p>Let\u2019s see how to <strong>install GDPR-compliant Google Maps on your website<\/strong> using My Agile Privacy<sup>\u00ae<\/sup>.<\/p>\n<p>Throughout this guide, references are made to style sheets, IDs, and JavaScript functions. Remember: always customize the code to adapt to your website\u2014this may include changing the ID, function names, or CSS styles as needed.<\/p>\n<p><strong>Note:<\/strong> Some themes or plugins may already use a cookieless version of the Google Maps API. If the external code loads from \"maps.googleapis.com\" (rather than \"maps.google.com\" or \"maps-api-ssl.google.com\"), it is already operating without cookies. You may still choose to use a preemptive block if your theme or plugin allows this, or simply enable the \"Google Maps Widget\" cookie in \"necessary\" mode.<\/p>\n<h2>Solution 1 \u2013 Automatic Scan<\/h2>\n<p>You can use the advanced \"Cookie Shield\" feature, which automatically detects Google Maps.<br \/>\nSet the Shield to \"Learning\" mode and browse your site's pages; detected content will be set to privacy-compliant mode.<br \/>\nAlternatively, you can use manual configuration.<\/p>\n<h2>Solution 2 \u2013 Manual Configuration<\/h2>\n<p><em>Note: This configuration is intended for advanced\/custom installations, typically by developers or in custom themes.<\/em><\/p>\n<h3>Part 1 \u2013 Include the Google Script in Consent-Managed Codes<\/h3>\n<p>Google Maps requires an external script for proper operation, which looks like this:<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-4918 size-full\" src=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_1.png\" alt=\"Google Maps code\" width=\"2560\" height=\"348\" srcset=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_1.png 2560w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_1-300x41.png 300w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_1-1024x139.png 1024w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_1-768x104.png 768w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_1-1536x209.png 1536w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_1-2048x278.png 2048w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><br \/>\nThe key parameters in the script are:<\/p>\n<ul>\n<li><em>key<\/em>: your unique API Key for Google Maps.<\/li>\n<li><em>callback<\/em>: the function called once the script loads successfully. In this example, it\u2019s called <code class=\"\" data-line=\"\">initMap<\/code>. You will need to provide this function for proper map initialization.<\/li>\n<\/ul>\n<p>We\u2019ll cover how to write the callback function below; for now, proceed with adding the Google script.<\/p>\n<h3>Part 2 \u2013 Adding the Google Maps Cookie in My Agile Privacy<sup>\u00ae<\/sup><\/h3>\n<p>In your WordPress admin area, go to <em>My Agile Privacy<sup>\u00ae<\/sup> \u2192 Cookie List<\/em> in the left menu.<br \/>\nHere, you'll find all cookies imported during plugin installation. By default, they will be in draft status\u2014publish only those relevant to your site.<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-5153 size-full\" src=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2022\/01\/lista-cookie-v2.jpg\" alt=\"cookie list\" width=\"1500\" height=\"772\" srcset=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2022\/01\/lista-cookie-v2.jpg 1500w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2022\/01\/lista-cookie-v2-300x154.jpg 300w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2022\/01\/lista-cookie-v2-1024x527.jpg 1024w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2022\/01\/lista-cookie-v2-768x395.jpg 768w\" sizes=\"(max-width: 1500px) 100vw, 1500px\" \/><br \/>\nThis screen provides columns like:<\/p>\n<ul>\n<li><em>Cookie Name<\/em>: Name of the cookie.<\/li>\n<li><em>Is Necessary<\/em>: Indicates if the cookie is essential for site functionality. If rejecting it makes the site unusable, it is marked as essential (this is pre-filled).<\/li>\n<li><em>Auto Update<\/em>: Shows whether the reference text is kept up to date automatically for GDPR compliance.<\/li>\n<li><em>Installation Type<\/em>: The method in which the cookie is included. This can be changed as needed; see the guides for more info.<\/li>\n<\/ul>\n<p>To add Google Maps support, locate \"Google Maps (Google Inc.)\" in the list and click on it.<br \/>\nThe detail page will show pre-filled information and two blank fields for code input.<br \/>\nWith \"Allow Automatic Update\" enabled, this information will be kept up to date automatically.<br \/>\nBelow, select \"Type of Installation\" (Javascript and Noscript, or Raw). Choose \"Raw Code\" to view the \"raw html code\" field.<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-4919 size-full\" src=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_2.jpg\" alt=\"entering the raw code\" width=\"1500\" height=\"853\" srcset=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_2.jpg 1500w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_2-300x171.jpg 300w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_2-1024x582.jpg 1024w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_2-768x437.jpg 768w\" sizes=\"(max-width: 1500px) 100vw, 1500px\" \/><\/p>\n<h3>Part 3 \u2013 Inserting the Google Maps Code<\/h3>\n<p>Paste the Google Maps script code into the \"Html Raw Code\" field as is.<br \/>\nThis is how it should look:<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-4920 size-full\" src=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_3.jpg\" alt=\"raw code entry - part 2\" width=\"1500\" height=\"392\" srcset=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_3.jpg 1500w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_3-300x78.jpg 300w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_3-1024x268.jpg 1024w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_3-768x201.jpg 768w\" sizes=\"(max-width: 1500px) 100vw, 1500px\" \/><br \/>\nRemember to save and publish the cookie by clicking the blue \"Publish\" button in the upper right corner.<\/p>\n<h3>Part 4 \u2013 The Callback Function<\/h3>\n<p>The script references a callback function (for example, <code class=\"\" data-line=\"\">initMap<\/code>). Add this function in your JavaScript file or in the footer of your template. Here\u2019s an example:<\/p>\n<pre><code class=\"language-javascript\" data-line=\"\">\n\/\/ Map initialization function\nfunction initMap() {\n  \/\/ Center point coordinates\n  const marker_ltn_lng = { lat: -25.344, lng: 131.036 };\n  \/\/ Center the map on the coordinates\n  const map = new google.maps.Map(document.getElementById(&quot;map&quot;), {\n    zoom: 4,\n    center: marker_ltn_lng,\n  });\n  \/\/ Place a marker at the coordinates\n  const marker = new google.maps.Marker({\n    position: marker_ltn_lng,\n    map: map,\n  });\n}\n<\/code><\/pre>\n<p>This function sets the map\u2019s coordinates and renders it inside a <code class=\"\" data-line=\"\">div<\/code> with the ID <code class=\"\" data-line=\"\">map<\/code>. Adjust the values as necessary for your implementation.<\/p>\n<h3>Part 5 \u2013 Add the Map Container in HTML<\/h3>\n<p>Insert a <code class=\"\" data-line=\"\">&lt;div id=&quot;map&quot;&gt;&lt;\/div&gt;<\/code> where you want the map displayed on your page.<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-4929 size-full\" src=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_4.png\" alt=\"map container code\" width=\"1920\" height=\"261\" srcset=\"https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_4.png 1920w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_4-300x41.png 300w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_4-1024x139.png 1024w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_4-768x104.png 768w, https:\/\/www.myagileprivacy.com\/wp-content\/uploads\/2021\/12\/gmaps_4-1536x209.png 1536w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><br \/>\n<strong>Important:<\/strong> The <code class=\"\" data-line=\"\">div<\/code> will be empty unless styled with CSS. For visibility, use this CSS or adapt it to your site\u2019s needs:<\/p>\n<pre><code class=\"language-css\" data-line=\"\">\n#map {\n  height: 400px;    \/* Map height *\/\n  width: 100%;      \/* Full-width *\/\n}\n<\/code><\/pre>\n<h2>Final Step \u2013 Verifying Operation<\/h2>\n<p>Once you've completed these steps, check whether Google Maps displays correctly.<br \/>\nWhen visiting the page, the map will only load after you have explicitly consented to cookie installation\u2014either by clicking \u201cI agree\u201d on the cookie bar or by activating the cookie under \"Customize\" in the cookie panel.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Maps allows you to display interactive maps directly on your website. With it, users can calculate routes, measure distances, view points of interest, addresses, and much more. Let\u2019s see how to install GDPR-compliant Google Maps on your website using My Agile Privacy\u00ae. Throughout this guide, references are made to style sheets, IDs, and JavaScript [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8718,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[33],"tags":[35],"class_list":["post-9072","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cookies","tag-free"],"acf":{"visibilita_box_autore":false,"autore_associato":null,"elenco_faq_articolo":null,"url_esterno":"","titolo":"Google Maps"},"_links":{"self":[{"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/posts\/9072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/comments?post=9072"}],"version-history":[{"count":11,"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/posts\/9072\/revisions"}],"predecessor-version":[{"id":15164,"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/posts\/9072\/revisions\/15164"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/media\/8718"}],"wp:attachment":[{"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/media?parent=9072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/categories?post=9072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myagileprivacy.com\/en\/wp-json\/wp\/v2\/tags?post=9072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}