Correctly adding Google analytics code

Discussion in 'Site Marketing' started by marketplace, Jul 1, 2010.

  1. marketplace New Member

    I tried to add analytics code to layout.tpl without success.

    In both cases, when added to in the end of the header or at the end of the body the site does not show at all.

    Is there something I may be over-looking?

    I could use some help on this. I would appreciate any suggestions.
    It's important for me to have google analytics tracking.

    Is there a plugin or addon that is in the works where users could just add the code into a field and save for it to be added to the proper area? I have that with other scripts I have an license for.
  2. seymourjames All Hands On Deck

    Are you doing it like this in your layout.tpl file

    {modulehook function="tpl_layout_footer" options=""}
    {literal}

    <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-12657XX29-1");
    pageTracker._trackPageview();
    } catch(err) {}</script>

    {/literal}
    </body>
    </html>
  3. marketplace New Member

    I left out the {literal} tags earlier.

    Thanks I think I got it right now.
  4. musikal Customer

    That works

    Thanks so much for the {literal} tags, got smarty errors before this.

Share This Page