Plugin Directory

Changeset 407213


Ignore:
Timestamp:
07/09/2011 01:58:39 AM (15 years ago)
Author:
cavemonkey50
Message:

Prevents post preview pages from being tracked and skewing stats.

Location:
google-analyticator/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • google-analyticator/trunk/google-analyticator.php

    r407210 r407213  
    845845        if ( ( get_option(key_ga_admin) == ga_enabled || !ga_current_user_is(get_option(key_ga_admin_role)) ) && get_option(key_ga_admin_disable) == 'remove' || get_option(key_ga_admin_disable) != 'remove' )
    846846        {
    847             # Add the notice that Google Analyticator tracking is enabled
    848             echo "<!-- Google Analytics Tracking by Google Analyticator " . GOOGLE_ANALYTICATOR_VERSION . ": http://ronaldheft.com/code/analyticator/ -->\n";
     847            # Disable the tracking code on the post preview page
     848            if ( !function_exists("is_preview") || ( function_exists("is_preview") && !is_preview() ) )
     849            {
     850                # Add the notice that Google Analyticator tracking is enabled
     851                echo "<!-- Google Analytics Tracking by Google Analyticator " . GOOGLE_ANALYTICATOR_VERSION . ": http://ronaldheft.com/code/analyticator/ -->\n";
    849852           
    850             # Add the Adsense data if specified
    851             if ( get_option(key_ga_adsense) != '' )
    852                 echo '<script type="text/javascript">window.google_analytics_uacct = "' . get_option(key_ga_adsense) . "\";</script>\n";
     853                # Add the Adsense data if specified
     854                if ( get_option(key_ga_adsense) != '' )
     855                    echo '<script type="text/javascript">window.google_analytics_uacct = "' . get_option(key_ga_adsense) . "\";</script>\n";
    853856           
    854             # Include the file types to track
    855             $extensions = explode(',', stripslashes(get_option(key_ga_downloads)));
    856             $ext = "";
    857             foreach ( $extensions AS $extension )
    858                 $ext .= "'$extension',";
    859             $ext = substr($ext, 0, -1);
    860 
    861             # Include the link tracking prefixes
    862             $outbound_prefix = stripslashes(get_option(key_ga_outbound_prefix));
    863             $downloads_prefix = stripslashes(get_option(key_ga_downloads_prefix));
    864             $event_tracking = get_option(key_ga_event);
    865 
    866             ?>
     857                # Include the file types to track
     858                $extensions = explode(',', stripslashes(get_option(key_ga_downloads)));
     859                $ext = "";
     860                foreach ( $extensions AS $extension )
     861                    $ext .= "'$extension',";
     862                $ext = substr($ext, 0, -1);
     863
     864                # Include the link tracking prefixes
     865                $outbound_prefix = stripslashes(get_option(key_ga_outbound_prefix));
     866                $downloads_prefix = stripslashes(get_option(key_ga_downloads_prefix));
     867                $event_tracking = get_option(key_ga_event);
     868
     869                ?>
    867870<script type="text/javascript">
    868871    var analyticsFileTypes = [<?php echo strtolower($ext); ?>];
     
    874877</script>
    875878<?php
    876             # Add the first part of the core tracking code
    877             ?>
     879                # Add the first part of the core tracking code
     880                ?>
    878881<script type="text/javascript">
    879882    var _gaq = _gaq || [];
     
    881884<?php
    882885       
    883             # Add any tracking code before the trackPageview
    884             do_action('google_analyticator_extra_js_before');
    885             if ( '' != $extra )
    886                 echo "  $extra\n";
     886                # Add any tracking code before the trackPageview
     887                do_action('google_analyticator_extra_js_before');
     888                if ( '' != $extra )
     889                    echo "  $extra\n";
    887890           
    888             # Add the track pageview function
    889             echo "  _gaq.push(['_trackPageview']);\n";
     891                # Add the track pageview function
     892                echo "  _gaq.push(['_trackPageview']);\n";
    890893           
    891             # Add the site speed tracking
    892             if ( get_option(key_ga_sitespeed) == ga_enabled )
    893                 echo "  _gaq.push(['_trackPageLoadTime']);\n";
    894        
    895             # Disable page tracking if admin is logged in
    896             if ( ( get_option(key_ga_admin) == ga_disabled ) && ( ga_current_user_is(get_option(key_ga_admin_role)) ) )
    897                 echo "  _gaq.push(['_setCustomVar', 'admin']);\n";
    898        
    899             # Add any tracking code after the trackPageview
    900             do_action('google_analyticator_extra_js_after');
    901             if ( '' != $extra_after )
    902                 echo "  $extra_after\n";
    903        
    904             # Add the final section of the tracking code
    905             ?>
     894                # Add the site speed tracking
     895                if ( get_option(key_ga_sitespeed) == ga_enabled )
     896                    echo "  _gaq.push(['_trackPageLoadTime']);\n";
     897       
     898                # Disable page tracking if admin is logged in
     899                if ( ( get_option(key_ga_admin) == ga_disabled ) && ( ga_current_user_is(get_option(key_ga_admin_role)) ) )
     900                    echo "  _gaq.push(['_setCustomVar', 'admin']);\n";
     901       
     902                # Add any tracking code after the trackPageview
     903                do_action('google_analyticator_extra_js_after');
     904                if ( '' != $extra_after )
     905                    echo "  $extra_after\n";
     906       
     907                # Add the final section of the tracking code
     908                ?>
    906909
    907910    (function() {
     
    912915</script>
    913916<?php
     917            }
    914918        } else {
    915919            # Add the notice that Google Analyticator tracking is enabled
  • google-analyticator/trunk/readme.txt

    r407210 r407213  
    5555* Replaces deprecated tracking code _setVar with _setCustomVar.
    5656* Improves the account select dropdown by organizing the accounts. Props bluntly.
     57* Prevents post preview pages from being tracked and skewing stats.
    5758
    5859= 6.1.3 =
Note: See TracChangeset for help on using the changeset viewer.