ThemeShaper Forums » Thematic

[closed]

google analytics code in child theme?

(3 posts)
  • Started 9 years ago by stevewynn
  • Latest reply from Caramboo
  • This topic is not resolved
  1. stevewynn
    Member

    Sorry, Im quite new at this so please bear with me. Sorry if this is obvious, but i just want to make sure i am doing everything correctly.

    Im trying to add the google analytics code to my footer.php in my Thematic setup.

    I am using the child theme Earlymorning. As i understand I should inject the google analytics code in the child theme's footer.php.

    Is this correct?

    </div><!-- #main -->
    
        <?php
    
        // action hook for placing content above the footer
        thematic_abovefooter();
    
        ?>    
    
    	<div id="footer">
    
            <?php
    
            // action hook creating the footer
            thematic_footer();
    
            ?>
    
    	</div><!-- #footer -->
    
        <?php
    
        // actio hook for placing content below the footer
        thematic_belowfooter();
    
        ?>  
    
    </div><!-- #wrapper .hfeed -->
    
    <?php 
    
    // calling WordPress' footer action hook
    wp_footer();
    
    // action hook for placing content before closing the BODY tag
    thematic_after(); 
    
    ?>
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("XXXXX");
    pageTracker._setDomainName(".XXXXX");
    pageTracker._trackPageview();
    } catch(err) {}</script>
    </body>
    </html>
    Posted 9 years ago #
  2. I've just been using the "google analytics for wordpress" plugin, which does this automatically..

    Posted 9 years ago #
  3. Caramboo
    Member

    Put this in your functions.php file:

    function analytic_footer() {?>
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    _uacct = "UA-1234567-2";
    urchinTracker();
    </script>
    <? }
    add_filter ('thematic_after', 'analytic_footer');
    

    Obviously replace the 1234567...

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.