var _gaq = _gaq || []; _gaq.push(['_setAccount', '$unbounce_analytics_id']); _gaq.push(['_trackPageview']); setTimeout(function() { window.onscroll = function() { window.onscroll = null; // Only track the event once _gaq.push(['_trackEvent', 'scroll', 'read']); } }, 30000); (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); })(); _TRACKING_CODE_; // Check if current user is logged in and is author or higher. Echo code only if condition is false. if (!current_user_can('edit_published_posts')) { echo $tracking_script; } else { echo ""; } } /* Plugin front end work ends here, next is about options and database handling */ /* *** Add Plugins Optinos Under Settings *** */ add_action ('admin_menu', 'unbounce_admin_menu'); function unbounce_admin_menu() { add_options_page( 'Analytics Code', 'Analytics Code', 'manage_options', 'analytics-unbounce', 'unbounce_options'); } function unbounce_options() { global $unbounce_analytics_id; if ( !current_user_can( 'manage_options' ) ) { wp_die( __('You do not have sufficient permissions to access this page.') ); } $unbounce_message = ''; if (array_key_exists('unbounce_submit', $_POST)) { $unbounce_message = unbounce_check_analytics_key(); } echo <<<_UNBOUNCE_OPTIONS_