User Tools

Site Tools


res:plugins:lordloh:googleanalytics

Google Analytics plugin

create a 'googleanalytics/' folder, and create the plugin.googleanalytics.php file with the contents below. Make sure to change UA-xxxxxx-x to your google tracking ID. Add googleanalytics to the plugins panel to activate.

<?php
/*
Plugin Name: Google Analytics
Plugin URI: http://lohlogics.co.nr/blogs
Description: Adds the google analytics trackng code
Author: Lord Loh.
Version: 1.0
Author URI: http://lohlogics.co.nr/blogs
*/ 
 
function plugin_googleAnalytics() {
?>
<script type="text/javascript">
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-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}</script>
<?php
}
add_action('wp_footer', 'plugin_googleAnalytics');
?>
res/plugins/lordloh/googleanalytics.txt · Last modified: 2019/01/12 17:53 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki