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.

<?php
add_action('wp_footer', 'googleanalytics');

function googleanalytics() { ?>
// Paste your Google Analytics code here
<script type="text/javascript">

 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-12453889-1']);
 _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>

<?php } ?>

Add a Comment

Your email address will not be published. Required fields are marked *