where to put google analytics code in wordpress blog

Answered wordpress question, where to put google analytics code in wordpress blog. Google analytics service is required in all the wordpress websites. For putting goolge analytics code in wordpress theme.

where to put google analytics code in wordpress blog

where to put google analytics code in wordpress blog
where to put google analytics code in wordpress blog

You can use the following code.

Open your functions.php file from wordpress theme folder and put following code in that file. You just need to put your google analytics code instead of my code.

01<?php
02add_action('wp_footer', 'googleanalytics');
03 
04function googleanalytics() { ?>
05// Paste your Google Analytics code here
06<script type="text/javascript">
07 
08 var _gaq = _gaq || [];
09 _gaq.push(['_setAccount', 'UA-12453889-1']);
10 _gaq.push(['_trackPageview']);
11 
12 (function() {
13 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
14 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
15 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
16 })();
17 
18</script>
19 
20<?php } ?>