logo

NJP

Google Analytics

Import · Jul 26, 2011 · article

Have you heard of Google Analytics? Have you wanted to use it with your Service-Now instance? You may have even noticed some code on the demo site suggesting an integration with Google Analytics. Here's how it can be done.Go to https://www.google.com/analytics and register an account (free).Create a profile for each instance; DEV, PRD QA etc...When adding the profile, you will be given some code to apply on the site.Make sure to check the option: "One domain with multiple subdomains".I've also modified the code to track some additional data(FYI: "UA-xxxxxxxx-x" will be generated to something of meaning once you add the profile, do not actually use UA-xxxxxxxx-x):

var _gaq = _gaq || [];_gaq.push(['_setAccount', 'UA-xxxxxxxx-x]);_gaq.push(['_setDomainName', '.service-now.com']);_gaq.push(['_trackPageview']);_gaq.push(['_trackPageLoadTime']); //added this, you will also find this on the demo site(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();

Copy everything minus the script tags:

var _gaq = _gaq || [];_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);_gaq.push(['_setDomainName', '.service-now.com']);_gaq.push(['_trackPageview']);_gaq.push(['_trackPageLoadTime']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();

Take this and create a new UI Script and copy the contents into the script.I have found the tracking status does not show a connection until a few hours later.

Also, it will take up to 24 hours for data to start to generate.

View original source

https://www.servicenow.com/community/in-other-news/google-analytics/ba-p/2284054