If you have a Google Analytics account for tracking visitors to your website, you need to add the tracking code script into the <head> section of every page for your site. The code looks something like this:

<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-00000000-1', 'auto');
ga('send', 'pageview');

</script>

To add this to every page can be done differently depending on your template. Many 3rd Party templates will have a text box in the Template Manager interface when you can either add all the above script or they may have it set up so that all you need to do is enter the UA-000000-1 Google Account number.

There are also 3rd Party Extensions at http://extensions.joomla.orgsearch?q=analytics that will add the code in the proper location for you. 

How to add the Google Analytics Script with Protostar

Protostar is the default template for Joomla 3. Many web developers will use it as the basis for their custom template. The Protostar Template is bare bones and does not have many of the features of the paid templates.

You can add the Google Analytics Tracking code to the index.php in the Protostar Template and it will populate every page on your site with this information.

After making a safety backup, open the index.php that sits inside the protostar folder in a text editor. Locate the </head> element in the index.php file. Paste in the tracking code just before the </head> and save the index.php to your hosting server. Open your site in a browser window and look at the source code for the site. You should see this code on every page of the site in the <head> section.