# # # # #

MediaWikiへのGoogle Analyticsを設置(1.16.0 Vector)

skins/Vector.php の

// Output HTML Page
        $this->html( 'headelement' );
?>
        <div id="mw-page-base" class="noprint"></div>
        <div id="mw-head-base" class="noprint"></div>
        <!-- content --> 

// Output HTML Page
        $this->html( 'headelement' );
?>

<!-- Google Analytics -->
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXX']);
  _gaq.push(['_trackPageview']);

  (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);
  })();

</script>
<!-- /Google Analytics -->

        <div id="mw-page-base" class="noprint"></div>
        <div id="mw-head-base" class="noprint"></div>
        <!-- content --> 

とすればOK。

参考・引用

http://hpbegin.jugem.jp/?eid=29

最終更新: 2019年1月9日 (水) 08:09
# # # # #