Google Analytics: Get Back ISP, Service Provider, and Network Domain

In Google Analytics, you used to be able to see the “service provider” and “network domain” (also referred to as “ISP organization” and “ISP domain” in some areas of Google Analytics).

But now that Google Analytics no longer supports these dimensions, are we doomed never to be able to get this info again? Will we forever be stuck with the “(not set)” service provider?

Not a chance. All we need to do is get the data ourselves and then send it to Analytics. And to get our ISP data into Analytics, there are just 3 simply steps.

3 Simple Steps to Getting Back the Service Provider and Network Domain

  1. Create custom dimensions
  2. Modify your gtag code
  3. Retrieve and send the ISP data to Analytics

Note: If you’ve got Tag Manager on your site, I recommend using Simo Ahava’s solution instead.

Create custom dimensions

The first thing we need to do is create our custom dimensions.

In Google Analytics, navigate to the admin area. In the “property” column, click “Custom Definitions”. Then click “Custom Dimensions”.

Click the “+ New Custom Dimension” button.

In the “Name” field, enter “ISP”. Then, set the “Scope” to “Session”. Click “Create”.

Add two more custom dimensions. Set the scope of each to “Session”.

  • Service Provider
  • Network Domain

Note the “Index” of each of the custom dimensions. You’ll need these indices later.

Modify your gtag code

(If you’re using the old Universal Analytics tag rather than the new gtag, click here.)

The standard gtag code that you get from Analytics looks like this:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-512568-21"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-512568-21');
</script>

We need to modify this code slightly to prepare it to send custom dimensions. Our new gtag code will look like this:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-512568-21"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  
  gtag('config', 'UA-512568-21', {
    'custom_map': {
      'dimension1': 'isp',
      'dimension2': 'org',
      'dimension3': 'hostname'
    }
  });
</script>

Change the Analytics ID

If you’re copying and pasting the code above, be sure to set the Analytics ID to your own. So, replace “UA-512568-21” with whatever your ID is. Note that there are two spots where the ID appears.

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-512568-21"></script>
gtag('config', 'UA-512568-21', {

Set the indices of the custom dimensions

Remember those indices of the custom dimensions you created?

Make sure the indices in your Analytics code match the indices of your custom dimensions.

'dimension1': 'isp',
'dimension2': 'org',
'dimension3': 'hostname'

Note: You actually need the word “dimension” in there before each index.

If the indices of your custom dimensions were…

Custom Dimension NameIndexScope
ISP7Session
Service Provider8Session
Network Domain9Session

…then the dimensions in your Analytics code would be:

'dimension7': 'isp',
'dimension8': 'org',
'dimension9': 'hostname'

Retrieve and send the ISP data to Analytics

Copy the code below and paste it somewhere below your main Analytics code.

<script>
  var customDimensions = {};
  var Http = new XMLHttpRequest();
  var url = 'https://json.geoiplookup.io/';
  Http.open("GET", url);
  Http.send();
  
  Http.onreadystatechange = function() {
    if (this.readyState==4 && this.status==200) {
      var response = JSON.parse(Http.responseText);
      customDimensions = { 
        'isp': response.isp,
        'org': response.org,
        'hostname': response.hostname,
        'non_interaction': true
      };
      gtag('event', 'sendCustomDimensions', customDimensions );
    }
  }
</script>

If you operate a commercial website, you’ll need to purchase a license from geoiplookup.io.

Find the ISP, Service Provider, and Network Domain in Analytics

After you’ve collected some visitor data, go to your Analytics account. Pretty much any report will do. Click the “Secondary dimension” selector. Search for “service provider”.

Look for the custom dimension named “Service Provider”. (Note that Google Analytics still lets you see the old Service Provider dimension under “Users”. That’s not the one you want. You want the one under “Custom Dimensions”.)

You should now see the name of the ISP organization.

ISP Service Provider with Universal Analytics

If you’re using the legacy “Universal Analytics” instead of gtag, follow these steps instead.

Set up your custom dimensions

Set up your custom dimensions just as you did for the gtag implementation.

Do not modify your Analytics code

Retrieve and send the ISP data to Analytics

Copy and paste the following code below your main Universal Analytics code.

<script>
  var customDimensions = {};
  var Http = new XMLHttpRequest();
  var url = 'https://json.geoiplookup.io/';
  Http.open("GET", url);
  Http.send();
  
  Http.onreadystatechange = function() {
    if (this.readyState==4 && this.status==200) {
      var response = JSON.parse(Http.responseText);
      customDimensions = { 
        'dimension1': response.isp,
        'dimension2': response.org,
        'dimension3': response.hostname
      };
      ga('set', customDimensions);
    }
  }
</script>

Note that you may need to modify the dimension indices in the code if the indices of your custom dimensions are not 1, 2, and 3.

'dimension1': response.isp,
'dimension2': response.org,
'dimension3': response.hostname

2 thoughts on “Google Analytics: Get Back ISP, Service Provider, and Network Domain”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.