<?php/*Plugin Name: Google Analytics PageView TrackerDescription: Automatically add tracking code for Google Analytics to each page view by inserting the tracking script into the head tag.Version: 1.0Author: Jones S. CropperAuthor URI: http://www.callowcreation.comPlugin URI: https://bitbucket.org/snippets/caLLowCreation/8KprR/google-analytics-pageview-trackerLicense: GPL3License URI: https://www.gnu.org/licenses/gpl-3.0.txt*/functionwp_google_site_tracker(){?><!-- Google Analytics --><script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('send', 'pageview');
</script><!-- End Google Analytics --><?php}add_action('wp_head','wp_google_site_tracker');
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.