Dotclear


Ignore:
Timestamp:
12/03/09 14:31:55 (13 years ago)
Author:
xave
Message:

Handling of the new asynchronous method (cf.  http://googlecode.blogspot.com/2009/12/google-analytics-launches-asynchronous.html )

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/googleTools/_public.php

    r1695 r1936  
    2323     public static function publicHeadContent(&$core) 
    2424     { 
     25          $res = ''; 
     26           
    2527          if ($core->blog->settings->googlestuff_verify != "") { 
    26                $res = '<meta name="google-site-verification" content="'.$core->blog->settings->googlestuff_verify.'" />'."\n"; 
    27                echo $res; 
     28               $res .= '<meta name="google-site-verification" content="'.$core->blog->settings->googlestuff_verify.'" />'."\n"; 
    2829          } 
     30           
     31          if ($core->blog->settings->googlestuff_uacct != "") { 
     32               $res .= '<script type="text/javascript">'."\n". 
     33                    'var _gaq = _gaq || [];'."\n". 
     34                    '_gaq.push([\'_setAccount\', \''.$core->blog->settings->googlestuff_uacct.'\']);'."\n". 
     35                    '_gaq.push([\'_trackPageview\']);'."\n". 
     36                    '</script>'."\n"; 
     37          } 
     38      
     39     echo $res; 
    2940     } 
    3041      
     
    3344          if ($core->blog->settings->googlestuff_uacct != "") { 
    3445               $res = '<script type="text/javascript">'."\n". 
    35                     'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");'."\n". 
    36                     'document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));'."\n". 
    37                     '</script>'."\n". 
    38                     '<script type="text/javascript">'."\n". 
    39                     'if (typeof(_gat) !=  "undefined") {'."\n". 
    40                     '    var pageTracker = _gat._getTracker("'. 
    41                     $core->blog->settings->googlestuff_uacct. 
    42                     '");'."\n". 
    43                     '    pageTracker._initData();'."\n". 
    44                     '    pageTracker._trackPageview();'."\n". 
    45                     '}'."\n". 
    46                     '</script>'."\n"; 
     46                    '(function() {'."\n". 
     47                    'var ga = document.createElement(\'script\');'."\n". 
     48                    'ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' :'. 
     49                         '\'http://www\') + \'.google-analytics.com/ga.js\';'."\n". 
     50                    'ga.setAttribute(\'async\', \'true\');'."\n". 
     51                    'document.documentElement.firstChild.appendChild(ga);'."\n". 
     52                    '})();'."\n". 
     53                    '</script>'; 
     54                     
    4755               echo $res; 
    4856          } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map