Put Google Analytics code into your wordpress theme

Put Google Analytics code into your wordpress theme

Adding Google Analytics is important for website. Here in this article we given code snippet and show to Put Google Analytics code into your wordpress theme

Put Google Analytics code into your wordpress theme

Copy paste following lines to your wordpress theme folder’s functions.php file.


function google_analytics() {

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-12453889-1");
pageTracker._trackPageview();
} catch(err) {}</script>
}
add_action('wp_footer', 'google_analytics');

Dont forget to replace your google analytics code in google_analytics code.

Put Google Analytics code into your wordpress theme
Put Google Analytics code into your wordpress theme

have fun!

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.