1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

JavaScript How to insert hit counter on "Open Cart"

Discussion in 'Web Development' started by Yvonne_SF, Dec 4, 2010.

  1. Yvonne_SF

    Yvonne_SF New Member

    hi there, is there anyone who know how to insert hit counter and google adsense on open cart e-commerce?
    Thanks in advance.
    Yvonne
     
  2. enigma1

    enigma1 New Member

    Which version are you using?

    For the adsense you need to access the catalog/view/theme/default/template/common/header.tpl or in that folder one of the other common files depending where you want the ads to be displayed. The insert the js code inside a div like:

    <script type="text/javascript"><!--
    google_ad_client = "pub-nnnn";
    google_ad_slot = "2182230932";
    google_ad_width = 234;
    google_ad_height = 60;
    //-->

    You need to setup the correct client number given by google for your account.

    For the analytics you need to access the catalog/view/theme/default/template/common/header.tpl

    Locate this line
    Code:
    <script type="text/javascript" src="catalog/view/javascript/jquery/jquery-1.3.2.min.js"></script>
    
    Right after add
    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">
    var pageTracker = _gat._getTracker("UA-xxxxxx-x");
    pageTracker._trackPageview();
    </script>
    
    Again you need to setup the UA-nnn to the id you got from google.

    If you need to monitor the visitors directly in your admin it will need a bit more work.
     
  3. Yvonne_SF

    Yvonne_SF New Member

    Thank you so much enigma1.

    Regards,
    Yvonne from San Francisco