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

Google Analytics e-commerce

This is a discussion on Google Analytics e-commerce within the osCmax v2 Customization/Mods forums, part of the osCmax v2.0 Forums category; I found this contrib on oscommerce: osCommerce Community Add-Ons In the installation file it gives these instructions: How to install ...

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


    Default Google Analytics e-commerce

    I found this contrib on oscommerce:

    osCommerce Community Add-Ons

    In the installation file it gives these instructions:

    How to install Google Analytics (beta) and E-commerce functionality?

    1. create a new directory 'analytics' in catalog/includes/modules/.

    result: catalog/includes/modules/analytics/.

    2. copy the file 'analytics.php' into this directory.

    if necessary, change the $transaction_string and/or the $item_string , for example
    if you do not use the value customers_state or affiliation tag, replace this with dummy text (company name description), like:

    $transaction_string = '"' . $order_id . '"," ' . $analytics_affiliation . '",
    "' . $analytics_total . '","' . $analytics_tax . '","' . $analytics_shipping . '",
    "' . $orders['customers_city'] . '","DUMMYTEXT","' . $orders['customers_country'] . '"';

    3. make a copy of your original footer.php in the directory catalog/includes/, rename this file to footer-tracker.php.

    4. The original contribution placed the Analytics tracking code in the header. A more convient way to place the tracker code, is at the end of the source code.
    Therefor: in the ORIGINAL footer.php place the following script at the end of the file

    <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>

    5. Replace the xxxxxxx-x in the script above with your personal Analytics UA-code (available in your Google Analytics account).

    6. open/edit catalog/checkout_success.php.

    7. Underneath <link rel="stylesheet" type="text/css" href="style.css"> paste the following 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();

    <?php
    include(DIR_WS_MODULES . 'analytics/analytics.php');
    ?>

    </script>

    8. Again (as in step 4), replace the xxxxxxx-x in the script above with your personal Analytics UA-code.

    9. At the bottom of the file checkout_success.php change the following line:

    <!-- footer //-->
    <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
    <!-- footer_eof //-->

    into

    <!-- footer //-->
    <?php require(DIR_WS_INCLUDES . 'footer-tracker.php'); ?>
    <!-- footer_eof //-->

    10. Save the checkout_success.php


    Every successful transaction made in your store is now trackable in Google Analytics. Navigate to the e-commerce overview: dashboard -> e-commerce

    Q: There is no button "e-commerce" in my Analytics menu
    A: E-commerce tracking is not enabled for your website. You can enable this in the profile settings of "Main Website Profile Information". Enable "Yes, an E-Commerce Site" to track your transactions.

    Q: Is it necessary to update from Urchin to the new Beta code?
    A: To be ahead of mandatory updates, yes. Google announced that the old Analytics Urchin tracking would be supported for at least 12 months.
    Can someone familiar with OSCMax translate these install instructions into ones compatible with OSCMax? Obviously because of the template system files such as footer.php no longer exist and as such without proper instructions many people wouldn't know how to install thsi contribution.

    I paid someone to do mine but it would also be nice to get feedback on how to do this so that I can check and troubleshoot if it doesn't work properly. Unfortunately with google you're stuck waiting 24 hours between code changes to see if your attempted fix worked or not.

  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 e-commerce

    footer is replaced with the end of main_page.tpl.php

    so anything that goes into footer.php should be at the bottom of 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 e-commerce

    tcshadow,
    Search the forum. I posted step by step instructions somewhere many months ago on how to install that exact contribution on OSCMAX (except the part where you modify the tracking for sales, but that is exactly the same in OSC and OSCMAX from what I remember)

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


    Default Re: Google Analytics e-commerce

    Quote Originally Posted by MindTwist View Post
    tcshadow,
    Search the forum. I posted step by step instructions somewhere many months ago on how to install that exact contribution on OSCMAX (except the part where you modify the tracking for sales, but that is exactly the same in OSC and OSCMAX from what I remember)
    I have read that thread and tried to do everything step by step but I'm simply not getting any e-commerce data through. that was the thread where i said I'm using the urchin code because the new ga.js didn't work properly.

    I'm out of ideas... nfi how to make it work.

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


    Default Re: Google Analytics e-commerce

    Oh, ok. You should specify then that your problem is related to your OSCMAX store being run on SSL, since you say it is working ok when you are not using HTTP.

    You paid someone to install it and now you want to see how he did it/what he changed? You should have backed your store FULLY before leting anyone touch it, and after he is finished, compare the BEFORE with the AFTER and see exactly what files he modified, and what changes he did.

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


    Default Re: Google Analytics e-commerce

    I know what he did... It's not working though. He did all the right things and I have also looked through and double checked everything was done right. It simply isn't working and I suspect this is because of BTS. I have not yet heard of anyone getting analytics e-commerce tracking working properly. And if they have, they haven't been open to share how they did it.

    basic analytics goal tracking works fine with the old urchin code but that will be phased out within the year. The new ga.js doesn't work properly when it is installed the same way as urchin. No one seems to be able to fix this or have an interest in fixing it though.

    I've seen lots of advice based on assumptions but no one is willing to say "this is what I did and I can prove it works". Because it doesn't. At least it's not in the slightest straight forward. I've even installed a vanilla oscmax to try it out and it simply doesn't work.

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


    Default Re: Google Analytics e-commerce

    Can't help then, sorry. I haven't bothered with the new code, and I do not have my store setup with https.

  8. #8
    osCMax Developer

    michael_s's Avatar
    Join Date
    Jul 2002
    Location
    Phoenix, AZ
    Posts
    19,907
    Rep Power
    568


    Default Re: Google Analytics e-commerce

    There are several ways to do this. Here is one simple way:

    1. Edit /catalog/includes/configure_bts.php and add a new main template definition.

    Under this on line 19:
    PHP Code:
    define('TEMPLATENAME_MAIN_PAGE''main_page.tpl.php'); 
    Add this:
    PHP Code:
    define('TEMPLATENAME_MAIN_PAGE2''main_page2.tpl.php'); 
    Next, after this block of code (lines 43-50) :
    PHP Code:
        case 'main':
        
    // default or main_page
          
    if(is_file(DIR_WS_TEMPLATES TEMPLATENAME_MAIN_PAGE)) {
              
    $path = (DIR_WS_TEMPLATES TEMPLATENAME_MAIN_PAGE);
          } else {
              
    $path = (DIR_WS_TEMPLATES_FALLBACK TEMPLATENAME_MAIN_PAGE);
          }
        break; 
    Add this:
    PHP Code:
       case 'main2':
        
    // default or main_page
          
    if(is_file(DIR_WS_TEMPLATES TEMPLATENAME_MAIN_PAGE2)) {
              
    $path = (DIR_WS_TEMPLATES TEMPLATENAME_MAIN_PAGE2);
          } else {
              
    $path = (DIR_WS_TEMPLATES_FALLBACK TEMPLATENAME_MAIN_PAGE);
          }
        break; 
    2. In /templates/aabox/main_page.tpl.php after this:

    PHP Code:
    <!-- footer_eof //-->
    <?php
    }
    ?>
    Add This:
    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> 
    3. Copy templates/aabox/main_page.tpl.php to main_page2.tpl.php.

    Then edit main_page2.tpl.php. After this:

    PHP Code:
    <link rel="stylesheet" type="text/css" href="<?php echo DIR_WS_TEMPLATES?>coolmenu.css">
    Add this:
    PHP Code:
        <script language="javascript" 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 language="javascript" type="text/javascript">
            var pageTracker = _gat._getTracker("UA-xxxxxxx-x");
            pageTracker._initData();
            pageTracker._trackPageview();
            
            <?php 
                
    include(DIR_WS_MODULES 'analytics/analytics.php'); 
            
    ?>
        
        </script>
    4. Make sure you follow the mod instructions on how to add your Google ID number to the above code.

    5. create a new directory 'analytics' in catalog/includes/modules/.

    result: catalog/includes/modules/analytics/.

    6. copy the file 'analytics.php' into this directory.

    if necessary, change the $transaction_string and/or the $item_string , for example
    if you do not use the value customers_state or affiliation tag, replace this with dummy text (company name description), like:

    PHP Code:
    $transaction_string '"' $order_id '"," ' $analytics_affiliation '",
        "' 
    $analytics_total '","' $analytics_tax '","' $analytics_shipping '",
        "' 
    $orders['customers_city'] . '","DUMMYTEXT","' $orders['customers_country'] . '"'
    7. Edit catalog/checkout_success.php and change this:
    PHP Code:
    include (bts_select('main'$content_template)); // BTSv1.5 
    To this:
    PHP Code:
      include (bts_select('main2'$content_template)); // BTSv1.5 
    That should do it.
    Michael Sasek
    osCMax Developer


    osCmax Installation Service
    - Have our professionals install osCmax on your server - same day service!
    osCmax 2.5 User Manual - the must have beginners guide to osCmax v2.5

    Stay Up To Date with everything osCMax:
    Free osCmax Newsletters - Security notices, New Releases, osCMax News
    osCmax on Twitter - Up to the minute info as it happens. Know it first.

    osCmax Documentation

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


    Default Re: Google Analytics e-commerce

    Many thanks Michael,

    I'll give this a go tonight on my sandbox and shoot through some transactions to see how it goes.

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


    Default Re: Google Analytics e-commerce

    I can successfully say that michaels instructions above worked - kind of.

    It registered 1 sale(the ecommerce part) last night. I did 2 test transactions. Urchin used to register a conversion even from your filtered ip. It may be that this current code correctly ignores the excluded IPs when it comes to conversions. ie if you do a test order and have a filter set up it won't show...

    I'm going to disable my filters now and see how it works...

Page 1 of 2 12 LastLast

LinkBacks (?)

  1. 01-07-2011, 04:42 AM

Similar Threads

  1. Google Analytics (beta) with E-commerce
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 06-22-2008, 01:13 PM
  2. Google Analytics (beta) with E-commerce
    By michael_s in forum New osCommerce Contributions
    Replies: 1
    Last Post: 06-07-2008, 12:43 PM
  3. Google Analytics (beta) with E-commerce
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 01-15-2008, 01:11 AM
  4. Google Analytics (beta) with E-commerce
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 01-14-2008, 03:42 AM
  5. Google Analytics (beta) with E-commerce
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 01-09-2008, 03:55 AM

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
  •