Detect if Google Analytics and Developer Media are loaded properly or not
This is for my own future reference. I need a way to check if Digital Media and Google Analytics JavaScript objects are loaded properly. There are browser's extensions such as Ghostery and Disconnect that will interfere or surrogate JavaScript objects and nullify the analytics behind the ads.
Here you go!
<script type="text/javascript">
window.addEventListener('load', function()
{
if(typeof DMAds==='undefined')
{
console.log('Developer Media is not loaded');
}
else
{
console.log('Developer Media is loaded');
}
if(window._gaq && (typeof window._gaq.I!== 'undefined'))
{
console.log('Classic Google Analytics is loaded');
}
else
{
console.log('Classic Google Analytics is not loaded');
}
console.log(window._gaq.I.prefix);
}, false);
</script>
If the browser viewing the page with above JavaScript codes equips with Ghostery or Disconnect. You will see Developer Media is not loaded
and Classic Google Analytics is not loaded
under your browser's Console
tab.
References:
https://marthijnhoiting.com/detect-if-someone-is-blocking-google-analytics-or-google-tag-manager/
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+6.7k Golang : How to get ECDSA curve and parameters data?
+2.6k Golang : Calculate a pip value and distance to target profit example
+9.9k Golang : error parsing regexp: invalid or unsupported Perl syntax
+6.6k Golang : Read file with ioutil
+4.6k Fix sudo yum hang problem with no output or error messages
+5.7k Golang : Emulate NumPy way of creating matrix example
+7.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+7.9k Golang : How to flush a channel before the end of program?
+4k Golang : Find change in a combination of coins example
+5.6k Gogland : Single File versus Go Application Run Configurations
+14.1k Golang : Generate thumbnails from images
+4.3k Get Facebook friends working in same company