diff --git a/readme.txt b/readme.txt index 9a04b6c..52c16bf 100644 --- a/readme.txt +++ b/readme.txt @@ -3,13 +3,21 @@ InaneCoding Piwik OpenCart Ecommerce VQmod ------------------------------------------------------ Source Repository: https://github.com/InaneCoding/Piwik-OpenCart-Ecommerce-VQMod Author: Kevin Bibby / InaneCoding.co.uk -Version: 1.0 -Release Date: 2014-02-17 +Version: 1.1 +Release Date: 2014-06-25 License: GNU General Public License (GPL) version 3 ------------------------------------------------------ +DONATE +------ +I DO do this in my spare time for the good of other people - I have released this mod for free in the spirit of the Open Source community, so anything you give to support me would be most appreciated and give me that little extra push to do more features and updates for you guys :) +Please donate if you use this mod and are able to give something: +http://inanecoding.co.uk/donate/ :) + + + DESCRIPTION ----------- Implements Piwik Ecommerce tracking for OpenCart; @@ -17,6 +25,7 @@ Implements Piwik Ecommerce tracking for OpenCart; > Tracks Ecommerce product views (category views not yet implemented) > Tracks Ecommerce cart add/update/delete > Tracks Ecommerce orders +> Tracks Site Searches OpenCart admin backend for modifying settings. Option to use Piwik Proxy Hide Url script to obfuscate the URL in the javascript code. Fully VQmod'ed up! Does NOT overwrite any core files. @@ -35,7 +44,7 @@ If you have used a custom install path then please place the 'PiwikTracker.php' 4. The default install assumes that your OpenCart Admin directory is in the '/admin/' folder at the root of your OpenCart site. If you have used a custom Admin path then please place all files from '/upload/admin/' to your custom OpenCart Admin folder. -5. Only tested on OpenCart 1.5.1.3, 1.5.3.1 & 1.5.4.1, VQmod 2.1.6 & 2.1.7, and Piwik 1.8.4, 1.9.1 & 1.11.1. +5. Only tested on OpenCart 1.5.1.3, 1.5.3.1 & 1.5.4.1, 1.5.6.4 VQmod 2.1.6 & 2.1.7, and Piwik 1.12 & Piwik 2.30 (though think works down to ~1.9 ish). (may well work on others - please tell me what you find out!) @@ -46,22 +55,21 @@ INSTALL 2) Login to your OpenCart admin, go to the Extensions -> Modules page, and click 'Install' next to 'Piwik OpenCart Ecommerce mod'. 3) After install, click 'Edit' next to 'Piwik', and on the settings page enter the details about your site and the Piwik installation; -a) "Piwik installation URL" - This is the full url to your Piwik installation (including 'http://'). e.g. "http://www.example.com/piwik/". This MUST include the trailing '/' on the end! -b) "Piwik installation URL (https)" - Same as above, but for secure https. e.g. "https://www.example.com/piwik/". This MUST include the trailing '/' on the end! -c) "Full path to the PiwikTracker.php file" - As the name says, this is your server filepath to your PiwikTracker.php file in your Piwik folder - commonly this will be "/home/~user/public_html/piwik/PiwikTracker.php", where '~user' is replaced by your website hosting username. However this can vary depending on the server configuration. -d) "Piwik auth token" - This is your secret Piwik authorisation token. Get this from the 'API' tab on your Piwik admin panel. -e) "Piwik Site ID" - This is the ID used in your Piwik install for the site you want to track, usually this is '1' but can vary if you have multiple sites or a custom setup. Consult the 'Website Management' page on your Piwik admin panel for this setting (under Settings -> Websites). -f) "Piwik Tracking" - Global 'Enabled' / 'Disabled' setting for the Piwik OpenCart mod. -g) "Ecommerce tracking" - Set this to 'Enabled' to allow tracking of Ecommerce actions such as product views, cart operations and orders. Set this to 'Disabled' if you only wish to track regular page views. -h) "Piwik Proxy Script" - Set this to 'Enabled' to route all Piwik tracking requests through the Piwik Proxy script at the root of your site; useful if the "Piwik Installation URL" is at another URL/server which you don't want to make public. -i) "Piwik SKU" - Select what product field you would like to use when reporting the SKU (Stock Keeping Unit) in an Ecommerce operation. This can use either the 'Model' or 'SKU' fields which every product in OpenCart has. +a) "Piwik installation URL" - This is the full url to your Piwik installation (without 'http://'). e.g. "www.example.com/piwik/". +b) "Full path to the PiwikTracker.php file" - As the name says, this is your server filepath to your PiwikTracker.php file in your Piwik folder - commonly this will be "/home/~user/public_html/piwik/PiwikTracker.php", where '~user' is replaced by your website hosting username. However this can vary depending on the server configuration. +c) "Piwik auth token" - This is your secret Piwik authorisation token. Get this from the 'API' tab on your Piwik admin panel. +d) "Piwik Site ID" - This is the ID used in your Piwik install for the site you want to track, usually this is '1' but can vary if you have multiple sites or a custom setup. Consult the 'Website Management' page on your Piwik admin panel for this setting (under Settings -> Websites). +e) "Piwik Tracking" - Global 'Enabled' / 'Disabled' setting for the Piwik OpenCart mod. +f) "Ecommerce tracking" - Set this to 'Enabled' to allow tracking of Ecommerce actions such as product views, cart operations and orders. Set this to 'Disabled' if you only wish to track regular page views. +g) "Piwik Proxy Script" - Set this to 'Enabled' to route all Piwik tracking requests through the Piwik Proxy script at the root of your site; useful if the "Piwik Installation URL" is at another URL/server which you don't want to make public. +h) "Piwik SKU" - Select what product field you would like to use when reporting the SKU (Stock Keeping Unit) in an Ecommerce operation. This can use either the 'Model' or 'SKU' fields which every product in OpenCart has. UPGRADE ------- To upgrade from a previous version simply upload the files from the new version as described in step 1) of the installation. -There should be no need to re-install anything or change any settings as I've tried to pay attention to backwards compatibility during development. +There should be no need to re-install anything else or change/restore any settings as I've tried to pay attention to backwards compatibility during development. Please get in touch if you experience any issues. @@ -76,14 +84,20 @@ Some files will still remain - however these should be perfectly safe and not af LIMITATIONS ----------- -This is the first widespread release but would still benefit from further feedback. Please report any bugs found! +This is one of the first widespread release but would still benefit from further feedback. Please report any bugs found! 1) There is no functionality (yet) to track the category during page views / cart updates / orders. +2) Some small limitations to site search; OC 1.5.5 or newer doesn't track the search category, OC older than 1.5.5 does track the category but displays site search separate to the page view in the visitor log. VERSION HISTORY --------------- +v1.1 - 2014/06/25 +Fix error messages for undefined variables; checks GET values and other array elements are set before using. +Fixed 'mod disabled' footer comment so it doesn't get included in visible HTML (thanks github user glennw!). +Fixed minor error in Readme Install HTTP/HTTPS instructions. + v1.0 - 2014/02/17 First version to be listed on opencart.com extension store (jump to v1.0). Order tracking now called from success page (fixes issue with order attributed to payment processor). @@ -129,6 +143,7 @@ Feel free to raise new issues if you find anything which could be improved (or e DONATE ------ I DO do this in my spare time for the good of other people - I have released this mod for free in the spirit of the Open Source community, so anything you give to support me would be most appreciated and give me that little extra push to do more features and updates for you guys :) +Please donate if you use this mod and are able to give something: http://inanecoding.co.uk/donate/ :) @@ -136,3 +151,5 @@ http://inanecoding.co.uk/donate/ :) WITH THANKS TO -------------- Gordon Downie - for his brilliant code contribution to add the install and settings functionality to OpenCart admin. +Github User glennw - for his bug report and fix for 'mod disabled' footer comment. + diff --git a/upload/catalog/model/tool/piwik.php b/upload/catalog/model/tool/piwik.php index b491990..3d3444a 100644 --- a/upload/catalog/model/tool/piwik.php +++ b/upload/catalog/model/tool/piwik.php @@ -70,7 +70,7 @@ private function setEcommerceView() { /* Get the Category info */ // First, check the GET variable 'path' is set // Set to false - category reporting not fully supported in this version - if (false) { + if (isset($this->request->get['path']) and false) { //Initialise variables etc $piwik_category = ''; @@ -215,7 +215,7 @@ public function trackSiteSearch($search_keyword = NULL, $search_category_id = NU if ($this->piwik_enable) { if (version_compare(VERSION, '1.5.5.0', '>=')) { // >= 1.5.5 so use javascript method (when called from the PHP page this is then unusued) - if ($this->request->get['route'] == "product/search") { + if (isset($this->request->get['route']) and isset($this->session->data['last_search_total']) and $this->request->get['route'] == "product/search") { // If on a search page, return a bit of javascript to set the number of results on piwik. return "_paq.push(['setCustomUrl', document.URL + '&search_count=" . $this->session->data['last_search_total'] . "']);"; } else { @@ -224,8 +224,7 @@ public function trackSiteSearch($search_keyword = NULL, $search_category_id = NU } else { // < 1.5.5 so use PHP method (only if called with correct arguments, so won't run when called from javascript). - if (isset($search_keyword) && isset($search_results_total)) { - + if (isset($search_keyword) and isset($search_results_total)) { // If the visitors piwik ID has been stored in the session data, // Then use this info to force the visitor ID used for the piwik API call. @@ -234,12 +233,18 @@ public function trackSiteSearch($search_keyword = NULL, $search_category_id = NU $this->t->setVisitorId($this->session->data['piwik_visitorid']); } + //Set the default category title + $category_title = ''; + // Get the search category, if it was specified if (isset($search_category_id)) { + // Get the category info from the ID $category_info = $this->model_catalog_category->getCategory($search_category_id); - $category_title = urldecode($category_info['name']); - } else { - $category_title = ''; + + if (isset($category_info['name'])) { + // If the name is specified then use this as for search tracking + $category_title = urldecode($category_info['name']); + } } // Track the site search diff --git a/upload/vqmod/xml/piwik.xml b/upload/vqmod/xml/piwik.xml index 6c966f3..f1cf806 100644 --- a/upload/vqmod/xml/piwik.xml +++ b/upload/vqmod/xml/piwik.xml @@ -67,7 +67,7 @@ session->data['order_id']) && ( ! empty($this->session->data['order_id'])) ) { + if ( isset($this->session->data['order_id']) and ( ! empty($this->session->data['order_id'])) ) { $this->session->data['last_order_id'] = $this->session->data['order_id']; $this->load->model('tool/piwik'); @@ -83,8 +83,13 @@ load->model('tool/piwik'); - $this->session->data['last_search_total'] = $product_total; - $this->model_tool_piwik->trackSiteSearch($filter_name, $filter_category_id, $product_total); + if ( isset($product_total) ) { + $this->session->data['last_search_total'] = $product_total; + + if ( isset($filter_name) and isset($filter_category_id) ) { + $this->model_tool_piwik->trackSiteSearch($filter_name, $filter_category_id, $product_total); + } + } // EOF - Piwik Opencart mod ]]>