Google Analytics Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • handiyman
    Member
    • Dec 2007
    • 42
    • 4.0.0

    [Forum] Google Analytics Error

    I am trying to add google analytics code in the footer section of the template. When I try to save the template, I am getting
    The following error occurred when attempting to evaluate the template 'footer':

    Parse error: syntax error, unexpected '[' in */includes/adminfunctions_template.php(4597) : eval()'d code on line 129

    This is likely caused by a malformed conditional statement.
    I tried the asynchronous analytics code which can be added to the header section.. in vb's case in the headinclude template, I am getting
    The following error occurred when attempting to evaluate the template 'headinclude':

    Parse error: syntax error, unexpected '[' in */includes/adminfunctions_template.php(4597) : eval()'d code on line 68

    This is likely caused by a malformed conditional statement.
    * -> I have removed the directory path and included only the error portion path only.

    Is any one faced similar problem> any help to fix this is appreciated
  • Dody
    Senior Member
    • Aug 2004
    • 1896
    • 3.8.x

    #2
    can you post your google analytic code?
    while(true){
    if(
    $someone->needsHelp() && $i->canHelp()) $post->help();
    if(
    $i->findBug()) $post->bug();
    }

    Comment

    • handiyman
      Member
      • Dec 2007
      • 42
      • 4.0.0

      #3
      The normal analytics script
      <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-XXXXX-X");
      pageTracker._trackPageview();
      } catch(err) {}</script>
      The Asynchronus script..
      <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); })();</script>
      XXXXX-X is replaced with analytics number.

      Comment

      • Paul M
        Former Lead Developer
        vB.Com & vB.Org
        • Sep 2004
        • 9886

        #4
        There is a known bug in 4.0 when it comes across javascript containing { followed by var

        The answer, I believe, is to enclose the whole section in <vb:literal> </vb:literal> tags.
        Baby, I was born this way

        Comment

        • Dody
          Senior Member
          • Aug 2004
          • 1896
          • 3.8.x

          #5
          Paul is right, use the following code:

          HTML Code:
          <vb:literal>
          {vb:raw ad_location.ad_footer_end} 
          </div>
          <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-XXXXX-X");
          pageTracker._trackPageview();
          } catch(err) {}</script> 
          </vb:literal>
          while(true){
          if(
          $someone->needsHelp() && $i->canHelp()) $post->help();
          if(
          $i->findBug()) $post->bug();
          }

          Comment

          • handiyman
            Member
            • Dec 2007
            • 42
            • 4.0.0

            #6
            Yep. That fixed the problem.. Thanks Paul and Dody for your help

            Comment

            • p3gator
              New Member
              • Nov 2004
              • 13
              • 3.8.x

              #7
              Awesome, thanks for the post, it worked great for me!

              Comment

              • abdulbasitsaeed
                Member
                • Apr 2009
                • 63
                • 4.0.x

                #8
                Thank you for this, Paul and Dody.

                Have reported this as a bug as well.
                PakFellows Forums - A Pakistani Forum & Social Network

                Comment

                • sokrates4612
                  Member
                  • Jul 2007
                  • 34
                  • 4.0.0

                  #9
                  This works for me only when <vb:literal> is right before GA code, like this:
                  Code:
                  {vb:raw ad_location.ad_footer_end} 
                  [COLOR=#000080]</div>[/COLOR]
                  [COLOR=#000080]<vb:literal>[/COLOR]
                  [COLOR=#800000]<script type=[COLOR=#0000ff]"text/javascript"[/COLOR]>[/COLOR]
                  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"));
                  [COLOR=#800000]</script>[/COLOR]
                  [COLOR=#800000]<script type=[COLOR=#0000ff]"text/javascript"[/COLOR]>[/COLOR]
                  try {
                  var pageTracker = _gat._getTracker("UA-XXXXX-X");
                  pageTracker._trackPageview();
                  } catch(err) {}[COLOR=#800000]</script>[/COLOR] 
                  [COLOR=#000080]</vb:literal>[/COLOR]
                  But now I have another problem - Google Analytics don´t count any visits. My grafs on Analytics website shows zero visits... even that the code is on the right place in the footer. Where is the problem?

                  Comment

                  • icarusforde
                    Senior Member
                    • Feb 2009
                    • 1594
                    • 3.8.x

                    #10
                    Do you have the right tracking code installed?

                    Comment

                    • Dody
                      Senior Member
                      • Aug 2004
                      • 1896
                      • 3.8.x

                      #11
                      Replace UA-XXXXX-X with your tracking number.
                      while(true){
                      if(
                      $someone->needsHelp() && $i->canHelp()) $post->help();
                      if(
                      $i->findBug()) $post->bug();
                      }

                      Comment

                      • FamilyCorner
                        Member
                        • Jan 2002
                        • 91

                        #12
                        Worked great for me too, thank you!

                        I also had to place the literal codes around my ad banner tags to get my banners to display.

                        Comment

                        • sokrates4612
                          Member
                          • Jul 2007
                          • 34
                          • 4.0.0

                          #13
                          Yes, that was the problem - wrong UA code... thanks!

                          Comment

                          • abdulbasitsaeed
                            Member
                            • Apr 2009
                            • 63
                            • 4.0.x

                            #14
                            Seems they didn't fix it with 4.0.1 either.
                            PakFellows Forums - A Pakistani Forum & Social Network

                            Comment

                            • Mermaid
                              Senior Member
                              • Mar 2008
                              • 761
                              • 3.6.x

                              #15
                              Originally posted by abdulbasitsaeed
                              Seems they didn't fix it with 4.0.1 either.
                              Or 4.0.2

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...