www.webdeveloper.com
Results 1 to 4 of 4

Thread: noob: 2 hours on Google Analytic and can't get my code right - Google won't monitor

  1. #1
    Join Date
    Aug 2013
    Posts
    10

    noob: 2 hours on Google Analytic and can't get my code right - Google won't monitor

    Hello!

    I have a simple website. HTML based with a simple script inside (don't know if that's relevant).

    Google Analytics says this:

    "Paste your snippet (unaltered, in itís entirety) into every web page you want to track. Paste it immediately before the closing </head> tag."

    Ok so here is what I did (this is from my index.html file):

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <LINK REL="SHORTCUT ICON" HREF="http://www.lbwbtc.com/favicon.ico">      
    <br>
    <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-46265609-1', 'lbwbtc.com');
      ga('send', 'pageview');
    
    </script>
    </head>

    And it won't work!
    What am I missing here?
    H E L P

  2. #2
    Join Date
    Oct 2013
    Location
    3rd planet from the sun
    Posts
    171
    try this before the closing </body> tag

    Code:
    <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("UA-xxxxxx-x");
    pageTracker._trackPageview();
    } catch(err) {}</script>

  3. #3
    Join Date
    Oct 2013
    Posts
    491
    Also, <br> cannot be inside a <head>

  4. #4
    Join Date
    Aug 2013
    Posts
    10
    Thank you !!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles