{"id":91790,"date":"2025-02-16T14:17:16","date_gmt":"2025-02-16T14:17:16","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/fetch-ip-geolocation-data-using-google-tag-manager\/"},"modified":"2025-02-16T14:17:16","modified_gmt":"2025-02-16T14:17:16","slug":"fetch-ip-geolocation-data-using-google-tag-manager","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=91790","title":{"rendered":"Fetch IP Geolocation Data Using Google Tag Manager"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<blockquote>\n<p><strong>Update 6 April 2020<\/strong>: I updated the template in the gallery to the latest version of the <a href=\"https:\/\/ipgeolocation.io\/documentation\/ip-geolocation-api-jquery-sdk.html\">IP Geolocation API SDK<\/a>, which no longer requires jQuery. Also, the SDK now handles API request caching to browser storage automatically, so the \u201cEnable Session Storage\u201d option was added to the template.<\/p>\n<\/blockquote>\n<p>My latest <a href=\"https:\/\/www.simoahava.com\/analytics\/custom-templates-guide-for-google-tag-manager\/\">custom tag template<\/a> tackles a use case I\u2019ve referred to a number of times before, especially in my article on <a href=\"https:\/\/www.simoahava.com\/analytics\/send-weather-data-to-google-analytics-in-gtm-v2\/\">sending weather data to Google Analytics<\/a>. The problem is two-fold:<\/p>\n<ul>\n<li>How to fetch the user\u2019s IP address into <code>dataLayer<\/code><\/li>\n<li>How to get <em>latitude<\/em> and <em>longitude<\/em> (as well as other geographical) data into <code>dataLayer<\/code><\/li>\n<\/ul>\n<p>For this purpose, I\u2019ve created a new <a href=\"https:\/\/tagmanager.google.com\/\">Google Tag Manager<\/a> custom tag template that leverages the <a href=\"https:\/\/ipgeolocation.io\/\">IP Geolocation API<\/a> service. The API is inexpensive to use, and it offers HTTPS by default.<\/p>\n<div style=\"aspect-ratio: 924 \/ 515;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/ip-geolocation-api.jpg\" title=\"IP Geolocation API custom template\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"515\" width=\"924\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/ip-geolocation-api.jpg#ZgotmplZ\" alt=\"IP Geolocation API custom template\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>You can find the template in the <a href=\"https:\/\/tagmanager.google.com\/gallery\/#\/owners\/gtm-templates-simo-ahava\/templates\/ip-geolocation-api\">template gallery<\/a>.<\/p>\n<p>                <span class=\"simmer\"><br \/>\n  <span class=\"close\">X<\/span><\/p>\n<p>\n    <span class=\"fa fa-md fa-bell\"\/><br \/>\n    <strong>The Simmer Newsletter<\/strong>\n  <\/p>\n<p>\n    Subscribe to the <a href=\"https:\/\/www.simoahava.com\/newsletter\/\">Simmer newsletter<\/a> to get the latest news and content from Simo Ahava into your email inbox!\n  <\/p>\n<p>  <\/span><\/p>\n<h2 id=\"ip-geolocation-api\">IP Geolocation API<\/h2>\n<p>You can register for a <strong>free<\/strong> account at <a href=\"https:\/\/ipgeolocation.io\/\">https:\/\/ipgeolocation.io\/<\/a> to get an API key. If you register for a paid subscription, in addition to getting more quota (the free subscription only allows <strong>1,000 requests per day<\/strong>), you\u2019ll be able to use the template <em>without<\/em> exposing your API key to the public, so it\u2019s something you should really consider if geolocation and\/or IP resolution is what you want to do.<\/p>\n<p>Sign up at <a href=\"https:\/\/ipgeolocation.io\/signup.html\">https:\/\/ipgeolocation.io\/signup.html<\/a>.<\/p>\n<div style=\"aspect-ratio: 607 \/ 414;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/sign-up.jpg\" title=\"Sign up to ipgeolocation.io\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"414\" width=\"607\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/sign-up.jpg#ZgotmplZ\" alt=\"Sign up to ipgeolocation.io\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Once you\u2019ve signed up, you\u2019ll find the dashboard with your API key. You\u2019ll need this for the tag you create with the custom template.<\/p>\n<div style=\"aspect-ratio: 584 \/ 254;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/api-key.jpg\" title=\"API key\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"254\" width=\"584\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/api-key.jpg#ZgotmplZ\" alt=\"API key\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>If you\u2019ve opted for a <strong>paid plan<\/strong>, you can add the origin (e.g. <code>www.simoahava.com<\/code>) to the list of <strong>Request Origins<\/strong>. If you do this, you don\u2019t need to add the API key to the template.<\/p>\n<p>Once you have the API key, and once you\u2019ve downloaded the <a href=\"https:\/\/tagmanager.google.com\/gallery\/#\/owners\/gtm-templates-simo-ahava\/templates\/ip-geolocation-api\">custom template<\/a> into your container, you\u2019re ready to proceed!<\/p>\n<h2 id=\"create-the-tag\">Create the tag<\/h2>\n<p>Create a new tag, and use <strong>IP Geolocation API<\/strong> as the template.<\/p>\n<div style=\"aspect-ratio: 834 \/ 353;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/template-in-selector.jpg\" title=\"Template in the selector menu\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"353\" width=\"834\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/template-in-selector.jpg#ZgotmplZ\" alt=\"Template in the selector menu\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Then, fill in the tag fields. Make sure to add the <strong>API key<\/strong> fetched from your <a href=\"https:\/\/app.ipgeolocation.io\/\">IP Geolocation API dashboard<\/a>, <em>unless<\/em> you\u2019ve added the origin where the tag will fire to the list of <strong>Request Origins<\/strong> (see previous chapter).<\/p>\n<p>The other settings you can change are listed in the following chapters.<\/p>\n<p>You can add whatever trigger you want to the tag. A trigger such as <strong>All Pages<\/strong> is OK, because it will resolve the API call as the earliest convenience. You can also use a more detailed rule to prevent the tag from firing on every single page, or to defer it until Window Loaded or similar.<\/p>\n<p>The tag relies on the <strong>jQuery library<\/strong>. If your site doesn\u2019t already use it, the template will automatically load the minified jQuery library along with the API SDK.<\/p>\n<h3 id=\"data-layer-settings\">Data Layer Settings<\/h3>\n<p>If you\u2019re using some other name for the <strong>dataLayer<\/strong> structure than <code>dataLayer<\/code>, you must type it into the <strong>Data Layer global variable name<\/strong> field, or the solution will not work properly.<\/p>\n<p>The <strong>Custom event name<\/strong> field is where you can define what the value of the <code>event<\/code> key will be in the <code>dataLayer<\/code> object that contains the geolocation and IP address data.<\/p>\n<p>The <code>dataLayer<\/code> object itself will be listed under the key <code>geoData<\/code> and will look something like this:<\/p>\n<div style=\"aspect-ratio: 697 \/ 456;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/geodata.jpg\" title=\"Geo data\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"456\" width=\"697\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/geodata.jpg#ZgotmplZ\" alt=\"Geo data\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>By the way, I am not in <strong>Salo<\/strong>, but in <strong>Espoo<\/strong> (some 100 kilometres distance). Geolocation is <strong>not<\/strong> a perfect art when using IP lookups.<\/p>\n<h3 id=\"ip-address-settings\">IP Address Settings<\/h3>\n<p>The default is <strong>Client IP<\/strong>, which means it uses whatever public IP address is assigned to the machine in use.<\/p>\n<p>If you want, you can also provide a <strong>Custom IP<\/strong> in case you\u2019ve resolved the IP some other (more reliable, perhaps) way. The Custom IP can take a hard-coded value (not sure why you\u2019d ever do so, though), or you can use a GTM variable for it. For example, to load the IP from a Data Layer Variable named <code>DLV - user.ip<\/code>, you could do this:<\/p>\n<div style=\"aspect-ratio: 471 \/ 203;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/custom-ip.jpg\" title=\"Custom IP\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"203\" width=\"471\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/custom-ip.jpg#ZgotmplZ\" alt=\"Custom IP\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<h3 id=\"other-settings\">Other Settings<\/h3>\n<p>You can type a comma-separated list of fields to <em>only<\/em> include in the response by editing the <strong>Fields to include<\/strong> field.<\/p>\n<div style=\"aspect-ratio: 625 \/ 302;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/fields-to-include.jpg\" title=\"Fields to include\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"302\" width=\"625\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/fields-to-include.jpg#ZgotmplZ\" alt=\"Fields to include\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The example above would only include the <code>ip<\/code> (always included), <code>longitude<\/code>, and <code>latitude<\/code> fields in the response.<\/p>\n<p>Similarly, you can list fields you want to <em>exclude<\/em> from the response by editing the <strong>Fields to exclude<\/strong> field.<\/p>\n<p>Finally, you can change the language of some of the response values by switching the <strong>Response language<\/strong> in the respective field. This might translate location names and other translatable values to the target language.<\/p>\n<h2 id=\"what-to-do-with-the-data\">What to do with the data<\/h2>\n<p>Once you\u2019ve got it up and running &#8211; what then?<\/p>\n<p>Well, a new object will be populated in <code>dataLayer<\/code> using the custom event name you\u2019ve set in the tag settings (<code>geolocate<\/code> by default). You can now fire tags that require IP or geolocation data using a Custom Event trigger for this event name.<\/p>\n<div style=\"aspect-ratio: 520 \/ 382;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/custom-event.jpg\" title=\"Custom Event trigger\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"382\" width=\"520\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/custom-event.jpg#ZgotmplZ\" alt=\"Custom Event trigger\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The rest of the utilities would be <strong>Data Layer variables<\/strong> you create for the individual parts of the response you want to access. For example, a Data Layer variable for the user\u2019s IP address would look like this:<\/p>\n<div style=\"aspect-ratio: 482 \/ 316;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/dlv-geodata-ip.jpg\" title=\"IP address geodata\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"316\" width=\"482\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/dlv-geodata-ip.jpg#ZgotmplZ\" alt=\"IP address geodata\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>A Data Layer Variable for the user\u2019s <strong>latitude<\/strong> would look like this:<\/p>\n<div style=\"aspect-ratio: 527 \/ 320;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2020\/01\/geodata-latitude.jpg\" title=\"Latitude geodata\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"320\" width=\"527\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2020\/01\/geodata-latitude.jpg#ZgotmplZ\" alt=\"Latitude geodata\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>And so on and so forth.<\/p>\n<p>You can use these for a variety of things:<\/p>\n<ul>\n<li>Send geographical data to <a href=\"https:\/\/analytics.google.com\/\">Google Analytics<\/a> in order to benchmark the accuracy of the API or GA\u2019s own geolocation lookups<\/li>\n<li>Check the IP address against a range of \u201cinternal\u201d IP addresses to <a href=\"https:\/\/www.simoahava.com\/analytics\/block-internal-traffic-gtm\/\">flag the user as internal traffic using Google Tag Manager<\/a><\/li>\n<li>Use the <code>currency<\/code> data to establish a local currency by default for the user<\/li>\n<li>Use the <code>isp<\/code> and <code>organization<\/code> data to check ISP and network domain information about the user.<\/li>\n<\/ul>\n<h2 id=\"summary\">Summary<\/h2>\n<p>As always, there\u2019s <em>caveats galore<\/em> with IP lookups. So many users use VPNs these days to (understandably) mask their location. This makes any type of geolocation and IP resolution extremely unreliable on a larger scale.<\/p>\n<p>Similarly, even without a VPN, the accuracy is iffy at best. In the example used in the article, my location was resolved to be <strong>Salo<\/strong>, which is around 100 kilometres away from <strong>Espoo<\/strong> where the test data was generated.<\/p>\n<p>So I wouldn\u2019t put any UX value to this information &#8211; don\u2019t redirect the user based on the API response, don\u2019t tie any business critical logic to either IP or geolocation data, and don\u2019t assume the API has an even passable success rate.<\/p>\n<p>However, the use cases listed in the previous chapter are all more or less valid even with inaccurate data. You just need to shift your hypotheses from requiring exact, infallible answers to being satisfied with a broader spectrum of accuracy.<\/p>\n<p>In any case, there are use cases for inspecting IP address and geolocation data within the browser. Some of them have been listed in the previous chapter. This custom template was created to help with these use cases.<\/p>\n<p>Thank you for reading, and please share your questions, suggestions, and use cases in the comments of this article!<\/p>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Update 6 April 2020: I updated the template in the gallery to the latest version of the IP Geolocation API SDK, which no longer requires jQuery. Also, the SDK now handles API request caching to browser storage automatically, so the \u201cEnable Session Storage\u201d option was added to the template. My latest custom tag template tackles [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":91791,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[11603,44182,43589,1531,14495,1791],"dealstore":[],"offerexpiration":[],"class_list":["post-91790","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-data","tag-fetch","tag-geolocation","tag-google","tag-manager","tag-tag"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Fetch IP Geolocation Data Using Google Tag Manager - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=91790\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fetch IP Geolocation Data Using Google Tag Manager - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"Update 6 April 2020: I updated the template in the gallery to the latest version of the IP Geolocation API SDK, which no longer requires jQuery. Also, the SDK now handles API request caching to browser storage automatically, so the \u201cEnable Session Storage\u201d option was added to the template. My latest custom tag template tackles [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=91790\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-16T14:17:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"924\" \/>\n\t<meta property=\"og:image:height\" content=\"515\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=91790#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=91790\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"Fetch IP Geolocation Data Using Google Tag Manager\",\"datePublished\":\"2025-02-16T14:17:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=91790\"},\"wordCount\":1194,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=91790#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg\",\"keywords\":[\"Data\",\"Fetch\",\"Geolocation\",\"Google\",\"Manager\",\"TAG\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=91790#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=91790\",\"url\":\"https:\/\/fivemor.com\/?p=91790\",\"name\":\"Fetch IP Geolocation Data Using Google Tag Manager - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=91790#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=91790#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg\",\"datePublished\":\"2025-02-16T14:17:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=91790#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=91790\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=91790#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg\",\"width\":924,\"height\":515},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=91790#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fetch IP Geolocation Data Using Google Tag Manager\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fetch IP Geolocation Data Using Google Tag Manager - Som2ny Network","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fivemor.com\/?p=91790","og_locale":"en_US","og_type":"article","og_title":"Fetch IP Geolocation Data Using Google Tag Manager - Som2ny Network","og_description":"Update 6 April 2020: I updated the template in the gallery to the latest version of the IP Geolocation API SDK, which no longer requires jQuery. Also, the SDK now handles API request caching to browser storage automatically, so the \u201cEnable Session Storage\u201d option was added to the template. My latest custom tag template tackles [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=91790","og_site_name":"Som2ny Network","article_published_time":"2025-02-16T14:17:16+00:00","og_image":[{"width":924,"height":515,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=91790#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=91790"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"Fetch IP Geolocation Data Using Google Tag Manager","datePublished":"2025-02-16T14:17:16+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=91790"},"wordCount":1194,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=91790#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg","keywords":["Data","Fetch","Geolocation","Google","Manager","TAG"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=91790#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=91790","url":"https:\/\/fivemor.com\/?p=91790","name":"Fetch IP Geolocation Data Using Google Tag Manager - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=91790#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=91790#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg","datePublished":"2025-02-16T14:17:16+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=91790#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=91790"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=91790#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/1739715440_ip-geolocation-api.jpg","width":924,"height":515},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=91790#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"Fetch IP Geolocation Data Using Google Tag Manager"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/91790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=91790"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/91790\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/91791"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=91790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=91790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=91790"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=91790"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=91790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}