Ok, there is many modules for doing this but you can just add it to your theme simply, saves needing to add extra modules and they code to your install.
Get the Google analytics code
Go to https://www.google.com/analytics/ and login in to the site, using the new version makes this simpler I feel. so click new version at the top(This will become the latest at one point anyways.)
Now click the little cog in the top right corner.
Then add new account, and follow the steps.
You will then get some code a little like this, we will copy this in later
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-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>
Drupal 7 bartik theme
Now open up the template.php file in your bartik theme.
In the function bartik_preprocess_html() we are going to use the command drupal_add_js()
So add drupal_add_js('COPY CODE FROM GOOGLE HERE', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)); under the two drupal_add_css commands.
Save this and upload back to the server.
Drupal 6 pixturerr theme
Now Open up the page.tpl.php file in your theme.
Before the closing tag of the body (</body>), add the code you got from google.
Upload back to the server.
You will have to repeat this for every page-SOMETHING.tpl.php.

Add new comment