The modul can't add google analytics code

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
pmolds
Forum Members
Forum Members
Posts: 12
Joined: Sat Nov 21, 2009 4:49 am

The modul can't add google analytics code

Post by pmolds »

Today, I want to add the google analytics code to my index page, but there is a problem when I add the code to index modul and can't active the google analytics, it say:

Tracking Not Installed (Last checked: Jan 31, 2010 6:54:32 AM )
The Google Analytics tracking code has not been detected on your website's home page. For Analytics to function, you or your web administrator must add the code to each page of your website.

and my website show below issue on the top page:

string(113) "Smarty error: [in tpl_head:23 line 7]: syntax error: unrecognized tag 'var' (Smarty_Compiler.class.php, line 590)" string(109) "Smarty error: [in tpl_head:23 line 8]: syntax error: unrecognized tag: (Smarty_Compiler.class.php, line 446)" string(110) "Smarty error: [in tpl_head:23 line 8]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)"

I paste the index page modul here:




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"));


try {
var pageTracker = _gat._getTracker("UA-12756110-1");
pageTracker._trackPageview();
} catch(err) {}

{metadata}

{sitename}
{stylesheet}
{cms_selflink dir="start" rellink=1}
{cms_selflink dir="prev" rellink=1}
{cms_selflink dir="next" rellink=1}
{* Relational links for interconnections between pages, good for accessibility and Search Engine Optmization *}



{* The above JavaScript is required for Menu - NCleanBlue-css to work in IE6 *}

{* the literal below and the /literal at the end are needed whenever there are {"curly brackets"} as smarty will think it's something to process and will throw an error *}
{* IE6 png fix *}
{literal}



// argument is a CSS selector
DD_belatedPNG.fix('.sbar-top,.sbar-bottom,.main-top,.main-bottom,#version');


/* enable background image caching in IE6 */
html {filter:expression(document.execCommand("BackgroundImageCache", false, true));}


{/literal}
 
 
   
     
       
{* Horizontal ruler that is hidden for visual browsers by CSS *}
{* Start Header, with logo image that links to the default start page *}
       
       

         
           
           
           
         
       

{* Start Navigation, style sheet  "Layout: NCleanBlue", starting at Menu  ROOT *}
          Navigation
{* anything class="accessibility" is hidden for visual browsers by CSS *}
         
          {menu template='cssmenu_ulshadow.tpl'}
         
         
{* End Navigation *}

       
{* End Header *}

{* Start Content (Navigation and Content columns) *}
       

{* Start Bar *}
         
{* Start Breadcrumbs, a bit of letting you know where your at *}
           
              {breadcrumbs starttext='You are here' root='Home' delimiter='»'}
           
{* End Breadcrumbs *}

           
         
{* End Bar *}

{* Start left side *}
         
           
              News
           
           
{* Start News *}
             
              {news number='3' detailpage='news'}
             
{* End News *}
           
             



            Contact Us
           
           
{* Start News *}
             
             

             
             
{* End News *}
           
             
         


{* End left side *}

{* Start Content Area, right side *}
         

{* main top, holds top image and print image *}
           
             
                {print showbutton=true}
             
           
         
{* main content *}
           
              {title}
            {content}
           
           
{* Start main bottom and relational links *}
           
             
              {anchor anchor='main' text='^  Top'}
             
             
               
                  {cms_selflink dir="previous" label="Previous page: "} 
{* The label parameter doesn't need to be there if you're using English, but is here to show how it's used if you don't want the English text "Previous page" *}
               
               
                  {cms_selflink dir="next"} 
               
             
{* End relational links *}

             
           
{* End main bottom *}

         
{* End Content Area, right side *}

       
{* End Content *}

     
{* end pagewrapper *}
       

{* Start Footer *}
     
       
{* edit the footer in the Global Content Block called "footer" *}
         
            {global_content name='footer'}
                   
           
       
     
{* End Footer *}
   
{* End Div *}



what is wrong with the page, How I do to correct it?
Help me, pleaseeeeeeeeeeeee
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm

Re: The modul can't add google analytics code

Post by Jos »

You might want to use {literal} and {/literal} around your Google code.  8)
pmolds
Forum Members
Forum Members
Posts: 12
Joined: Sat Nov 21, 2009 4:49 am

Re: The modul can't add google analytics code

Post by pmolds »

Thanks for your kindly help.
I will try it.
You mean add the code between the {literal}{/literal}. as below?
{literal}

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"));


try {
var pageTracker = _gat._getTracker("UA-xxxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}{/literal}
pmolds
Forum Members
Forum Members
Posts: 12
Joined: Sat Nov 21, 2009 4:49 am

Re: The modul can't add google analytics code

Post by pmolds »

Thanks Jos, it is working well.
good man
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: The modul can't add google analytics code

Post by Dr.CSS »

BTW that is supposed to go at the bottom of the template just above the ...
djwmedia
Forum Members
Forum Members
Posts: 42
Joined: Thu Sep 18, 2008 2:21 pm

Re: The modul can't add google analytics code

Post by djwmedia »

WORKED FOR ME! SOLVED!

PS can u explain more about the tribut Literal

I think it means! Dont mess with the code. Becease thats what it did before!

Greets
Dylan
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm

Re: The modul can't add google analytics code

Post by Jos »

Read all about the literal tag here: http://www.smarty.net/manual/en/languag ... iteral.php
Post Reply

Return to “Modules/Add-Ons”