Last active
January 18, 2016 10:08
-
-
Save Robbertdk/b1bb5519686938b8aa98 to your computer and use it in GitHub Desktop.
Google Analytics include in Wordpress themes functions.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_theme_google_analytics() { ?> | |
<script> | |
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]= | |
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date; | |
e=o.createElement(i);r=o.getElementsByTagName(i)[0]; | |
e.src='//www.google-analytics.com/analytics.js'; | |
r.parentNode.insertBefore(e,r)}(window,document,'script','ga')); | |
ga('create','GOOGLE ANALYTICS ID');ga('send','pageview'); | |
</script> | |
<?php } | |
if (!current_user_can('manage_options')) { | |
add_action('wp_footer', 'my_theme_google_analytics', 20); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment