-
-
Save cgrymala/b2930c808c6a3f65d0e5 to your computer and use it in GitHub Desktop.
Output the Analytics tracking information for UMW
This file contains 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
<?php | |
add_action( 'wp_print_scripts', 'umw_insert_analytics_code' ); | |
function umw_insert_analytics_code() { | |
if( is_admin() ) | |
return; | |
global $wpdb; | |
$sites = json_encode( array_flip( $wpdb->get_col( $wpdb->prepare( "SELECT domain FROM {$wpdb->site} ORDER BY id" ) ) ) ); | |
?> | |
<script type="text/javascript"> | |
var umw_internal_sites = <?php echo $sites ?>; | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']); | |
_gaq.push(['_setDomainName', 'none']); | |
_gaq.push(['_setAllowLinker', true]); | |
_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 | |
wp_enqueue_script( 'ga-external-tracker', plugins_url( '/analytics/ga-external-tracker.js', __FILE__ ), array( 'jquery' ), '0.2.15', true ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment