Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jun 2012
    Posts
    30
    Plugin Contributions
    0

    Default Re: Google Analytic s Question

    Thank you.

    Paste in the main body section?

  2. #2
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Google Analytic s Question

    Quote Originally Posted by PortFJ62 View Post
    Thank you.

    Paste in the main body section?
    Better, actually, to paste it into tpl_main_page.php, because that file has the closing </body> tag.

    Here are the last few lines of code of the CORE FILE.

    PHP Code:
    <!--bof- banner #6 display -->
    <?php
      
    if (SHOW_BANNERS_GROUP_SET6 != '' && $banner zen_banner_exists('dynamic'SHOW_BANNERS_GROUP_SET6)) {
        if (
    $banner->RecordCount() > 0) {
    ?>
    <div id="bannerSix" class="banners"><?php echo zen_display_banner('static'$banner); ?></div>
    <?php
        
    }
      }
    ?>
    <!--eof- banner #6 display -->
    </body>
    The Google code goes just above the </body> tag.

    <!--eof- banner #6 display -->
    <script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-37469995-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' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

    </script>

    </body>

    This is the "clunky" way to do things. It is BETTER (if you can) to use the plugin and the reason for this is that you can set various tracking parameters via the admin panel.

    For example, later on you may want to build in some custom tracking code, or assimilate AdWords Tracking with Analytics. The plugin allows you to administer these sorts of things more easily than you would by hard-coding the google scripts.

    But for now, if your analytics needs are simple, then do as I indicate above.

    BEAR IN MIND that tpl_main_page is a CORE FILE. You will need to create an edited OVER-RIDE and place this edited copy into your custom template's COMMON folder.

    EG:

    CORE FILE: /includes/templates/template_default/common/tpl_main_page.php
    OVERRIDE FILE: /includes/templates/YOUR_TEMPLATE_FOLDER/common/tpl_main_page.php
    20 years a Zencart User

  3. #3
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Google Analytic s Question

    Quote Originally Posted by schoolboy View Post
    BEAR IN MIND that tpl_main_page is a CORE FILE.
    And so is tpl_footer.php as suggested by someone else.

    That's why I suggested putting it in a completely separate self-contained jscript_.....php file so that nothing else needs messing with. The only downside is that it will load at the top of the page instead of the bottom. Not much of an issue, but some purists will say it makes their skin crawl to do that.


    So, as you can see, there are many ways to do it. Pick whichever you like.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Google Analytic s Question

    Quote Originally Posted by DrByte View Post
    That's why I suggested putting it in a completely separate self-contained jscript_.....php file so that nothing else needs messing with. The only downside is that it will load at the top of the page instead of the bottom. Not much of an issue, but some purists will say it makes their skin crawl to do that.
    With Analytics using asynchronous loading (text/javascript'; ga.async = true;)it should not matter whether it's in the header, or at the end of the </body> section.
    20 years a Zencart User

 

 

Similar Threads

  1. v139h Woopra analytic tracking identigy code in zencart website
    By snk060 in forum General Questions
    Replies: 4
    Last Post: 16 Jan 2014, 02:47 PM
  2. How do I insert google analytic to my zen cart website?
    By sunzhoujian in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 16 Aug 2009, 08:49 PM
  3. Analytic
    By ykaldes in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 6 Jan 2009, 04:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg