| 1 |
<?php |
| 2 |
add_action('wp_head', 'wp_insert_tracking_codes_wp_head'); |
| 3 |
function wp_insert_tracking_codes_wp_head() { |
| 4 |
$options = get_option('wp_insert_tracking_codes_options'); |
| 5 |
if($options['header']['status']) { |
| 6 |
echo $options['header']['code']; |
| 7 |
} |
| 8 |
} |
| 9 |
|
| 10 |
add_action('wp_footer', 'wp_insert_tracking_codes_wp_footer'); |
| 11 |
function wp_insert_tracking_codes_wp_footer() { |
| 12 |
$options = get_option('wp_insert_tracking_codes_options'); |
| 13 |
if($options['analytics']['status'] && ($options['analytics']['code'] != '')) { |
| 14 |
echo '<script type="text/javascript">'; |
| 15 |
echo 'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");'; |
| 16 |
echo 'document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));'; |
| 17 |
echo '</script>'; |
| 18 |
echo '<script type="text/javascript">'; |
| 19 |
echo 'var pageTracker = _gat._getTracker("'.$options['analytics']['code'].'");'; |
| 20 |
echo 'pageTracker._trackPageview();'; |
| 21 |
echo '</script>'; |
| 22 |
} |
| 23 |
if($options['footer']['status']) { |
| 24 |
echo $options['footer']['code']; |
| 25 |
} |
| 26 |
} |
| 27 |
?> |