• I recently followed the instructions for installing my google analytics code into the footer php. I am not good with this stuff and, unsurprisingly, it didn’t work. Instead, all it did was show the code right at the top of my published website.

    I decided to abandon any further attempts and removed the code from the stylesheet, and a strange thing has happened. When I’m logged in, the code has gone, however, when I log out I can see the code precisely where it was before at the top of my site – see for yourself https://tomashmore.net

    I’ve then gone back into the editor to see if the code is still there but it has gone. I don’t understand why it is still showing up on my website, nor how to get rid of it.

    Any ideas that could help me?

    Thanks

    Tom

Viewing 8 replies - 1 through 8 (of 8 total)
  • The code is not complete. Re-paste it and make sure you don’t miss even a character ??

    Also, I see that you are using w3 total cache

    so when logged out you see a cached page, when logged in you see a current page

    Clear your cache and the code should go away when logged out

    With a cache plugin, changes yo make live do not show up immediately to a nonadmin user

    You have something like right now:

    <script type="text/javascript">
    	var _gaq = _gaq || [];
    	_gaq.push(['_setAccount', 'UA-10646580-1']);
    	<script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-10646580-1']);
      _gaq.push(['_trackPageview']);
    
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    
    </script>_gaq.push(['_trackPageview']); _gaq.push(['_trackPageLoadTime']);(function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>

    Which is incomplete because the <script> tags are not placed properly. Review it in a HTML/PHP editor (like Notepad++ for example) and you’ll see the problem.

    Thread Starter tomashmore

    (@tomashmore)

    Adrian – There is no code where I originally put it. I’ve double checked and it’s gone, so I don’t understand why I’m still seeing something on the page, especially when it disappears when I’m logged in. I don’t want the google code anymore as I’ve found a different way to track my stats.

    And regarding seeing the problem, I have no idea how this type of coding works so seeing something is unlikely. My editing goes as far as,

    1. put something in
    2. sh*it, it didn’t work
    3. take it out

    Voodoo – That makes sense to try that, so I just emptied all cache’s, but it hasn’t worked. :0

    Thread Starter tomashmore

    (@tomashmore)

    I’ve deleted and re-installed my theme too, shouldn’t that have reset the stylesheet?

    technically, all that code is not the stylesheet.

    Your css files are stylesheets. The rest are php file. Or templates if you will

    If you put your code in the theme, reinstalling the theme will definitely reset everything

    The thing that’s happening is your analytics ccode is being applied twice…. somehow one block of code is being inserted inside another block of the same code, throwing it all out of whack

    Are you using any sort of plugin for analytics?

    What’s odd is, the 1st time I looked at your site, the code was at the bottom, in the foot section, now it’s in the head section, up top

    Thread Starter tomashmore

    (@tomashmore)

    Voodoo you’re an evil genius – it was a google plug-in that I forgot I had. I owe you a beer my friend! Thanks for taking the time to help me out ??

    Sweet! I’m glad we worked through that! (And I’m only partially evil!)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Strange line of code appears at top of website.’ is closed to new replies.