The MU forums have moved to

Where to Post Google Analytics Code (2 posts)

  1. hanz0122
    Posted 14 years ago #

    I registered to Google Analytics and they provided me with a code to post on every body-tag of the page that I want to be analyzed. Can someone give me a hint on where to find the body tag for every page? I tried searching on the codes but I can't HTML body tag. Most of them are php codes.

  2. SteveAtty
    Posted 14 years ago #

    Best place to put it is in the footer - and you can do that easily across all your themes (assuming they have a footer block) by creating a file and putting it in mu-plugins:

    function wpmu_footer($blah)
    $urchincode= <<< EOGS
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-3136964-1");
    } catch(err) {}</script>
    print $urchincode;
    return $blah;
    add_action('wp_footer', 'wpmu_footer');

    Put what ever code you need outputting between the <<<EOGS and EOGS lines

About this Topic

  • Started 14 years ago by hanz0122
  • Latest reply from SteveAtty