osCmax v2.5 User Manual
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Google Analytics

This is a discussion on Google Analytics within the osCommerce 2.2 Discussion forums, part of the osCommerce 2.2 Forums category; I want to install Google Analytics, which file do I need to add it to?...

      
  1. #1
    New Member
    Join Date
    Jun 2007
    Posts
    6
    Rep Power
    0


    Default Google Analytics

    I want to install Google Analytics, which file do I need to add it to?

  2. #2
    osCMax Development Team met00's Avatar
    Join Date
    Oct 2005
    Location
    wherever I happen to be at the moment
    Posts
    854
    Blog Entries
    2
    Rep Power
    26


    Default Re: Google Analytics

    /templates/yourtemplatename/main_page.tpl.php
    so endith the lesson
    <think>sometimes I just sit's and thinks</think>
    "Here you are with a hand full of holes, a thumb up your ass, and a big grin to pass the time of day with." - TWB

  3. #3
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Rep Power
    7


    Default Re: Google Analytics

    Just had to do this, and the search function saved me some time.

    The contrib I installed was the following:
    osCommerce: osCommerce Google Analytics module

    You need to make 3 changes on /templates/yourtemplatename/main_page.tpl.php :

    Find your stylesheets, which on my template are like this:

    Code:
     <link rel="stylesheet" type="text/css" href="<?php echo (bts_select('stylesheet','stylesheet.css')); // BTSv1.5 ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo (bts_select('stylesheet','print.css')); // BTSv1.5 ?>" media="print">
    Paste the following code AFTER it, replacing UA-XXXXXX-X with your google analytics account:

    Code:
             <?php
            // osCoders.biz - Analystics - start
            /*
            Conditional code added thank to  rrodkey and bfcase
            IMPORTANT -- IMPORTANT - IMPORTANT
            You'll need to update the "xxxx-x" in the samples (twice) above with your own Google Analytics account and profile number. 
            To find this number you can access your personalized tracking code in its entirety by clicking Check Status in the 
            Analytics Settings page of your Analytics account.
            */
             if ($request_type == 'SSL') {
            ?>    
             <script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript">
             </script>
             <script type="text/javascript">
               _uacct="UA-XXXXXX-X";
               urchinTracker();
             </script>
            <?php
            } else {
            ?>
             <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
             </script>
             <script type="text/javascript">
               _uacct="UA-XXXXXX-X";
               urchinTracker();
             </script>
            <?
            }
            // osCoders.biz - Analistics - end
            ?>
    Find your body tag:

    Code:
     <body>
    Replace with:

    Code:
     </head>
    // osCoders.biz - Analistics - start
    //     The onLoad="java script:__utmSetTrans()"  from the <body ... > tag
    //     was added for the Google Analytics contribution
    // osCoders.biz - Analistics - end
    <body onLoad="javascript:__utmSetTrans()">
    On my template I have no parameters on my <body>, if you have them, keep them and place the onLoad="javascript:__utmSetTrans()" at the end.

    And at the end, find the /body tag:

    Code:
     </body>
    And place right BEFORE it the following code:

    Code:
     <?php 
    // osCoders.biz - Analystics - start 
        include(DIR_WS_MODULES . 'analytics/analytics.php'); 
    // osCoders.biz - Analistics - end
    ?>
    Last, you need to upload the included file to /includes/modules/analytics/analytics.php

    Hopefully this is all that needs to be done, my Google Analytics account has checked my installation and said it is ok, and that it is gathering information and I will have my first reports no later than 24h from now.

  4. #4
    Active Member
    Join Date
    Nov 2004
    Location
    California
    Posts
    158
    Rep Power
    25


    Default Re: Google Analytics

    Well I am followed your directions I hope it works in 24 hrs too I'll post if it worked for me

  5. #5
    Active Member
    Join Date
    Nov 2004
    Location
    California
    Posts
    158
    Rep Power
    25


    Default Re: Google Analytics

    i get a string at the bottom of my screen after installing this... any idea what that is?

    "pageTracker._addTrans( "460"," ","2700.00","0.00","0.00","Houston","Texas","U SA" ); pageTracker._addItem( "460","1167","Sharp Dial Microwave R-21LCF","Microwave Ovens","249.00","12"); pageTracker._trackTrans(); "

  6. #6
    Active Member
    Join Date
    Aug 2007
    Posts
    145
    Rep Power
    5


    Default Re: Google Analytics

    Quote Originally Posted by met00 View Post
    /templates/yourtemplatename/main_page.tpl.php
    I put mine in this file and it won't pick up my checkout_success.php


    any ideas why?

    Oh I'm using the new code btw not urchin
    Last edited by tcshadow; 06-23-2008 at 01:12 PM.

  7. #7
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Rep Power
    7


    Default Re: Google Analytics

    So, what is "mine", and what it won't pick up?

  8. #8
    Active Member
    Join Date
    Aug 2007
    Posts
    145
    Rep Power
    5


    Default Re: Google Analytics

    PHP 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-xxxxxxx-x");
    pageTracker._initData();
    pageTracker._trackPageview();
    </script> 
    As far as I was aware this was supposed to work just fine in the secure pages... except it isn't.

    ie it works just fine and dandy on http pages and they show up in my analytics but none of the pages in https(ie past /checkout_shipping.php) show up..

    this means my goals aren't being tracked

  9. #9
    Active Member
    Join Date
    Aug 2007
    Posts
    145
    Rep Power
    5


    Default Re: Google Analytics

    I just did some more looking into it and it seems that it tracks all the way to /checkout_confirmation.php and then gets lost between there and my /checkout_success.php

    any idea why it's not recording /checkout_success.php?

  10. #10
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Rep Power
    7


    Default Re: Google Analytics

    No clue, sorry. I still use the old google analytics code (urchin) and I do not use SSL on my web page (just for CC transactions, and that is handled by me)

Page 1 of 2 12 LastLast

Similar Threads

  1. osCommerce Google Analytics module
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 06-21-2007, 02:01 PM
  2. osCommerce Google Analytics module
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 02-14-2007, 03:21 AM
  3. osCommerce Google Analytics module
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 02-13-2007, 01:50 PM
  4. Google-Analytics
    By dasmurphy in forum osCmax v2 Customization/Mods
    Replies: 3
    Last Post: 08-24-2006, 09:02 AM
  5. Reviews and google analytics
    By dasmurphy in forum osCmax v2 Installation issues
    Replies: 0
    Last Post: 08-15-2006, 05:28 PM

Bookmarks

Posting Permissions

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