i am using google analytics to track my site. They said to add a tracking.js code to my site in every page to track the site. For which i made a google_analytics.js file, wrote the code there and included this file in everypage i need to track. But Google Analytics page is saying that track is not installed!
0
votes
First off, google normally hosts the js file.. are you saying you downloaded it and are hosting it on your site? 2nd, did you include the rest of the on-page code, or did you just put a script include on your page? Who told you to do this? This sounds like really, really old instructions
- Crayon Violent
1 Answers
0
votes
Google analytics provide this service through two js - ga.js and another is analytics.js
For ga.js, you need to write following code in each html page of your site -
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(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);
})();
</script>
if you are using analytics.js, you need to write below code in each page of your site -
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXX-Y');
ga('send', 'pageview');
</script>
please see this link for more info -