WordPress.org

Ready to get started?Download WordPress

Forums

Can't get google analytics tracking code to work (3 posts)

  1. onandoffthegringotrail
    Member
    Posted 1 year ago #

    Hi

    I have inserted the google analytics tracking code in full into every page and post of my blog but Google Analytics gives 'Status: Tracking not installed' on the 'Tracking Info' tab. What's happening?

    My site is onandoffthegringotrail.com and the code looks like this:

    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-40******-2', 'onandoffthegringotrail.com');
    ga('send', 'pageview');

    </script>

  2. graphicgeek
    Member
    Posted 1 year ago #

    This should be inserted into the footer.php file or the header.php file of the theme, that way you don't have to insert it on every post and page. I suspect something may be getting garbled by the content editor, since the script is causing a javascript error.

    Alternately, you can use a plugin: http://wordpress.org/plugins/google-analytics-for-wordpress/

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    I do honestly recommend a plugin vs. adding code directly to the site.

    It's simpler and effective. The plugins do not add weight to your website, and you don't need to remember to copy over any code if you change themes in the future. I actually use the one recommended by @graphicsgeek on all of my sites.

Topic Closed

This topic has been closed to new replies.

About this Topic