That Software Guy! eCommerce Starts Here!

Installing phpTrafficA in your Zen Cart

Relevance: Any version of Zen Cart™

Donate: This is free software. Show your appreciation by supporting my efforts. Donate


The package phpTrafficA is an open source web analytics tool, written in php and mySQL. It can track access counts to your website, search engines, keywords, and referrers that lead to you, operating systems, web browsers, visitor retention, path analysis, and a lot more! A full demo is available on the home page.

Requirements:
Your system must have GD. To determine whether it does, go to Admin->Version (at the top right hand side of the screen), and scroll down until you see GD Support. The value should be "enabled."

Installation Instructions:
  1. Download zip or tarball from http://soft.zoneo.net/phpTrafficA/index.php
  2. Unzip or untar the package and copy to the home directory of your shop. In these instructions we will assume the new folder is called YOUR_SHOP/traffica, but you should pick another name (the same way you did for your admin folder).
  3. cd to YOUR_SHOP/traffica
  4. edit Php/config_sql.php, and set the parameters using the values from your includes/configure.php
  5. edit Php/config.php and set the admin password to one of your own choosing.
  6. Set these permissions:
    chmod 666 Php/sites.php:
    chmod 777 tmp:
  7. open YOUR_SHOP/traffica/Php/install.php in a web browser and follow the instructions. Specifically, be certain to erase these files from YOUR_SHOP/traffica/Php/ directory:

    rm confDB.sql.php confDBUpgrade.sql.php install.php upgrade.php

    (This is just like deleting zc_install after installing Zen; it ensures that bad guys can't re-install your system.) Note that confDBUpgrade.sql may not exist.
  8. Point your browser to YOUR_SHOP/traffica
    1. Login (using the password you set back in step 5.
    2. Press the "Config" button at the top of the screen.
    3. In Domain Address, enter yourshop.com. If your shop is in a subdirectory called shop, enter yourshop.com/shop
    4. In Table Name, I suggest using "phpTrafficA_" so that all tables are grouped together.
    5. Set "Trim" to "No".
    6. Press the "Submit" button.
    7. At the top of the screen, press the "Reminder" button.
    8. Keep this screen up; you will need it for the next step.
  9. Open up the file includes/application_top.php . Find $autoLoadConfig in this file. You want to paste in the code from the first row in the web page you opened in the previous step right before this. It will look something like this:
    ----
    
       $sid="281677";    // DO NOT COPY - example only 
       include("/var/www/html/mysite/traffica/write_logs.php"); // DO NOT COPY
    
       $autoLoadConfig = array();
       ... 
    -----
    
    You're done. Go to the admin screen www.yoursite.com/traffica and poke around. It takes a while for data to build up of course.
  10. If you have a test cart, and you don't want to run phpTrafficA on your test cart, take advantage of the fact that the hook for phpTrafficA was inserted after configure.php was included, so you can use your configuration to determine where you're running. For instance, on my cart, I say
      if (DB_SERVER_USERNAME != "scw") {
        $sid="281677";
        include("traffica/write_logs.php");
      }
    
  11. If you have a test cart and you do want to run phpTrafficA in both test and production, remember that the file traffica/Php/sites.php will be different on each site, just like your configure.php files are.


This tip was developed in April 2007.