tobiaswillmann.de

Use Network Information API and GTM to push your users real connection speed to Google Analytics

2019-05-17

Network Information API offers bandwidth and e.g. connection types like 4G

The Network Information interface provides information about the connection a device is using. It offers information about the bandwidth and the type of the connection

In the browser it can be used like this:

var con = navigator.connection || navigator.mozConnection || navigator.webkitConnetion
console.log(con.effectiveType)

It returns the effective type of the connection meaning one of ‘slow-2g’, ‘2g’, ‘3g’, or ‘4g’. With

console.log(con.downlink)

you get the effective bandwidth estimate in megabits per second, rounded to the nearest multiple of 25 kilobits per seconds.

So if you connect this with GTM and run it you get the connection speed of multiple users listed in GA.

Connect with GTM and GA

Go to GTM and create a custom javascript

connect this to to the Google Analytics Tag in GTM as a custom dimention.

The index number needs to be the same as in the definition you do in GA now

Check in Google Analytics

As hinted here the use of Network Information API is limited to some Browsers:

More about this

Google Analytics custom dimensions

https://support.google.com/tagmanager/answer/6164990?hl=en

Network​Information

https://support.google.com/tagmanager/answer/6164990?hl=en

Performance Budgets (Keep Request Counts Low And File Sizes Small)

https://support.google.com/tagmanager/answer/6164990?hl=en

© 2020 Tobias Willmann