function spool_analytics()
        {
            global $wp_query;
            // echo '<!--'.print_r($wp_query,1).'-->';
            $options = get_option('Yoast_Google_Analytics');
            if (!isset($options['uastring']) || $options['uastring'] == '') {
                if (current_user_can('manage_options')) {
                    echo "<!-- Google Analytics tracking code not shown because yo haven't chosen a Google Analytics account yet. -->\n";
                }
                return;
            }
            /**
             * The order of custom variables is very, very important: custom vars should always take up the same slot to make analysis easy.
             */
            $customvarslot = 1;
            if (yoast_ga_do_tracking() && !is_preview()) {
                $push = array();
                if ($options['allowanchor']) {
                    $push[] = "'_setAllowAnchor',true";
                }
                if ($options['allowlinker']) {
                    $push[] = "'_setAllowLinker',true";
                }
                if ($options['anonymizeip']) {
                    $push[] = "'_gat._anonymizeIp'";
                }
                if (isset($options['domain']) && $options['domain'] != "") {
                    $push[] = "'_setDomainName','" . $options['domain'] . "'";
                }
                if (isset($options['trackcrossdomain']) && $options['trackcrossdomain']) {
                    $push[] = "'_setDomainName','" . $options['primarycrossdomain'] . "'";
                }
                if (isset($options['allowhash']) && $options['allowhash']) {
                    $push[] = "'_setAllowHash',false";
                }
                if ($options['cv_loggedin']) {
                    $current_user = wp_get_current_user();
                    if ($current_user && $current_user->ID != 0) {
                        $push[] = "'_setCustomVar',{$customvarslot},'logged-in','" . $current_user->roles[0] . "',1";
                    }
                    // Customvar slot needs to be upped even when the user is not logged in, to make sure the variables below are always in the same slot.
                    $customvarslot++;
                }
                if (function_exists('is_post_type_archive') && is_post_type_archive()) {
                    if ($options['cv_post_type']) {
                        $post_type = get_post_type();
                        if ($post_type) {
                            $push[] = "'_setCustomVar'," . $customvarslot . ",'post_type','" . $post_type . "',3";
                            $customvarslot++;
                        }
                    }
                } else {
                    if (is_singular() && !is_home()) {
                        if ($options['cv_post_type']) {
                            $post_type = get_post_type();
                            if ($post_type) {
                                $push[] = "'_setCustomVar'," . $customvarslot . ",'post_type','" . $post_type . "',3";
                                $customvarslot++;
                            }
                        }
                        if ($options['cv_authorname']) {
                            $push[] = "'_setCustomVar',{$customvarslot},'author','" . GA_Filter::ga_str_clean(get_the_author_meta('display_name', $wp_query->post->post_author)) . "',3";
                            $customvarslot++;
                        }
                        if ($options['cv_tags']) {
                            $i = 0;
                            if (get_the_tags()) {
                                $tagsstr = '';
                                foreach (get_the_tags() as $tag) {
                                    if ($i > 0) {
                                        $tagsstr .= ' ';
                                    }
                                    $tagsstr .= $tag->slug;
                                    $i++;
                                }
                                // Max 64 chars for value and label combined, hence 64 - 4
                                $tagsstr = substr($tagsstr, 0, 60);
                                $push[] = "'_setCustomVar',{$customvarslot},'tags','" . $tagsstr . "',3";
                            }
                            $customvarslot++;
                        }
                        if (is_singular()) {
                            if ($options['cv_year']) {
                                $push[] = "'_setCustomVar',{$customvarslot},'year','" . get_the_time('Y') . "',3";
                                $customvarslot++;
                            }
                            if ($options['cv_category'] && is_single()) {
                                $cats = get_the_category();
                                if (is_array($cats) && isset($cats[0])) {
                                    $push[] = "'_setCustomVar',{$customvarslot},'category','" . $cats[0]->slug . "',3";
                                }
                                $customvarslot++;
                            }
                            if ($options['cv_all_categories'] && is_single()) {
                                $i = 0;
                                $catsstr = '';
                                foreach ((array) get_the_category() as $cat) {
                                    if ($i > 0) {
                                        $catsstr .= ' ';
                                    }
                                    $catsstr .= $cat->slug;
                                    $i++;
                                }
                                // Max 64 chars for value and label combined, hence 64 - 10
                                $catsstr = substr($catsstr, 0, 54);
                                $push[] = "'_setCustomVar',{$customvarslot},'categories','" . $catsstr . "',3";
                                $customvarslot++;
                            }
                        }
                    }
                }
                $push = apply_filters('yoast-ga-custom-vars', $push, $customvarslot);
                $push = apply_filters('yoast-ga-push-before-pageview', $push);
                if (is_404()) {
                    $push[] = "'_trackPageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
                } else {
                    if ($wp_query->is_search) {
                        $pushstr = "'_trackPageview','" . get_bloginfo('url') . "/?s=";
                        if ($wp_query->found_posts == 0) {
                            $push[] = $pushstr . "no-results:" . rawurlencode($wp_query->query_vars['s']) . "&cat=no-results'";
                        } else {
                            if ($wp_query->found_posts == 1) {
                                $push[] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=1-result'";
                            } else {
                                if ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) {
                                    $push[] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=2-5-results'";
                                } else {
                                    $push[] = $pushstr . rawurlencode($wp_query->query_vars['s']) . "&cat=plus-5-results'";
                                }
                            }
                        }
                    } else {
                        $push[] = "'_trackPageview'";
                    }
                }
                $push = apply_filters('yoast-ga-push-after-pageview', $push);
                if (defined('WPSC_VERSION') && $options['wpec_tracking']) {
                    $push = GA_Filter::wpec_transaction_tracking($push);
                }
                if ($options['shopp_tracking']) {
                    global $Shopp;
                    if (isset($Shopp)) {
                        $push = GA_Filter::shopp_transaction_tracking($push);
                    }
                }
                $pushstr = "";
                foreach ($push as $key) {
                    if (!empty($pushstr)) {
                        $pushstr .= ",";
                    }
                    $pushstr .= "[" . $key . "]";
                }
                if (current_user_can('manage_options') && $options['firebuglite'] && $options['debug']) {
                    echo '<script src="https://getfirebug.com/firebug-lite.js" type="text/javascript"></script>';
                }
                ?>

			<script type="text/javascript">//<![CDATA[
			// Google Analytics for WordPress by Yoast v<?php 
                echo GAWP_VERSION;
                ?>
 | http://yoast.com/wordpress/google-analytics/
			var _gaq = _gaq || [];
			_gaq.push(['_setAccount', '<?php 
                echo trim($options["uastring"]);
                ?>
']);
				<?php 
                if ($options["extrase"]) {
                    if (!empty($options["extraseurl"])) {
                        $url = $options["extraseurl"];
                    } else {
                        $url = plugins_url('custom_se_async.js', __FILE__);
                    }
                    echo '</script><script src="' . $url . '" type="text/javascript"></script>' . "\n" . '<script type="text/javascript">';
                }
                if ($options['customcode'] && trim($options['customcode']) != '') {
                    echo "\t" . stripslashes($options['customcode']) . "\n";
                }
                ?>
			_gaq.push(<?php 
                echo $pushstr;
                ?>
);
			(function () {
				var ga = document.createElement('script');
				ga.type = 'text/javascript';
				ga.async = true;
				ga.src = <?php 
                if ($options['gajslocalhosting'] && !empty($options['gajsurl'])) {
                    echo "'" . $options['gajsurl'] . "';";
                } else {
                    $script = 'ga.js';
                    if (current_user_can('manage_options') && $options['debug']) {
                        $script = 'u/ga_debug.js';
                    }
                    echo "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/" . $script . "';";
                }
                ?>

				var s = document.getElementsByTagName('script')[0];
				s.parentNode.insertBefore(ga, s);
			})();
			//]]></script>
			<?php 
            } else {
                if ($options["uastring"] != "") {
                    echo "<!-- Google Analytics tracking code not shown because users over level " . $options["ignore_userlevel"] . " are ignored -->\n";
                }
            }
        }