composer.json 0000666 00000002351 13066147041 0007275 0 ustar 00 { "name": "fooman/googleanalyticsplus", "type": "magento-module", "license": "OSL-3.0", "homepage": "https://github.com/fooman/googleanalyticsplus", "description": "Additional features for the default GoogleAnalytics module.", "authors": [ { "name": "Kristof Ringleff", "email": "kristof@fooman.co.nz" } ], "require": { "magento-hackathon/magento-composer-installer": "*", "fooman/common": "*" }, "extra": { "map": [ [ "app/code/community/Fooman/GoogleAnalyticsPlus/", "app/code/community/Fooman/GoogleAnalyticsPlus/" ], [ "app/design/frontend/base/default/layout/googleanalyticsplus.xml", "app/design/frontend/base/default/layout/googleanalyticsplus.xml" ], [ "app/design/frontend/base/default/template/fooman/googleanalyticsplus/", "app/design/frontend/base/default/template/fooman/googleanalyticsplus/" ], [ "app/etc/modules/Fooman_GoogleAnalyticsPlus.xml", "app/etc/modules/Fooman_GoogleAnalyticsPlus.xml" ] ] } } modman 0000666 00000001073 13066147041 0005751 0 ustar 00 app/code/community/Fooman/GoogleAnalyticsPlus/ app/code/community/Fooman/GoogleAnalyticsPlus/ app/design/frontend/base/default/layout/googleanalyticsplus.xml app/design/frontend/base/default/layout/googleanalyticsplus.xml app/design/frontend/base/default/template/fooman/googleanalyticsplus/ app/design/frontend/base/default/template/fooman/googleanalyticsplus/ app/etc/modules/Fooman_GoogleAnalyticsPlus.xml app/etc/modules/Fooman_GoogleAnalyticsPlus.xml app/etc/modules/Fooman_GoogleAnalyticsPlus.xml 0000666 00000000524 13066147041 0015527 0 ustar 00 true community app/code/community/Fooman/GoogleAnalyticsPlus/Block/GaConversion.php 0000666 00000007620 13066147041 0021604 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Block_GaConversion extends Fooman_GoogleAnalyticsPlus_Block_Common_Abstract { const URL_ADWORDS_CONVERSION = 'http://www.googleadservices.com/pagead/conversion.js'; const URL_ADWORDS_CONVERSION_SECURE = 'https://www.googleadservices.com/pagead/conversion.js'; protected $_quote; protected $_order; /** * helper to set the internal quote property * * @param $quote */ public function setQuote($quote) { $this->_quote = $quote; } /** * is adwords conversion tracking enabled * * @return bool */ public function isEnabled() { return Mage::getStoreConfigFlag('google/analyticsplus_classic/conversionenabled'); } /** * get Adword's conversion label from settings * can't be chosen freely since assigned from Google * * @return string */ public function getLabel() { return Mage::getStoreConfig('google/analyticsplus_classic/conversionlabel'); } /** * get a color - defaults to white * * @return string */ public function getColor() { return '#FFFFFF'; } /** * get the entered language * * @return string */ public function getLanguage() { return Mage::getStoreConfig('google/analyticsplus_classic/conversionlanguage'); } /** * get Google Adwords conversion id * * @return string */ public function getConversionId() { return Mage::getStoreConfig('google/analyticsplus_classic/conversionid'); } /** * get url for adwords conversion tracking secure/unsecure * * @return string */ public function getConversionUrl() { return ($this->getRequest()->isSecure()) ? self::URL_ADWORDS_CONVERSION_SECURE : self::URL_ADWORDS_CONVERSION; } /** * get no script url for adwords conversion tracking secure/unsecure * * @return string */ public function getNoScriptConversionUrl() { if ($this->getLabel()) { $url = sprintf( "//www.googleadservices.com/pagead/conversion/%s/?value=%s&label=%s&script=0", $this->getConversionId(), $this->getValue(), $this->getLabel() ); } else { $url = sprintf( "//www.googleadservices.com/pagead/conversion/%s/?value=%s&script=0", $this->getConversionId(), $this->getValue() ); } return $url; } /** * get conversion value, convert if chosen to a differnt currency * * @return int|string */ public function getValue() { $order = $this->_getOrder(); if ($order) { return Mage::helper('googleanalyticsplus')->convert($order, 'subtotal'); } else { return 0; } } /** * get order from the last quote id * * @return mixed */ protected function _getOrder() { if (!$this->_quote) { $ids = Mage::registry('googleanalyticsplus_order_ids'); $orderId = (is_array($ids) ? reset($ids) : null); if ($orderId) { $this->_order = Mage::getModel('sales/order')->load($orderId); } else { $this->_order = false; } } else { $this->_order = Mage::getModel('sales/order')->loadByAttribute('quote_id', $this->_quote->getId()); } return $this->_order; } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/Common/Abstract.php 0000666 00000013500 13066147041 0022174 0 ustar 00 getModuleDir('', 'Mage_Core') . DS . 'Helper' . DS; if (file_exists($coreHelperDir . 'Cookie.php')) { if (Mage::helper('core/cookie')->isUserNotAllowSaveCookie()) { return false; } } return true; } /** * determine if we are on the order success page * * @return bool */ public function isSuccessPage() { $handles = $this->getLayout()->getUpdate()->getHandles(); foreach (array_keys(Mage::getStoreConfig(self::XML_PATH_SUCCESS_PAGE_BLOCK_HANDLES)) as $handle) { if (in_array($handle, $handles)) { return true; } } return false; } /** * get product category for tracking purposes * either based on chosen category tracking attribute * or first category encountered * * @param $product * * @return mixed */ public function getProductCategory($product) { $attributeCode = Mage::getStoreConfig('google/analyticsplus/categorytrackingattribute'); if ($attributeCode) { if ($product->getResource()->getAttribute($attributeCode)) { $attributeValue = $product->getAttributeText($attributeCode); if (!$attributeValue) { return $product->getDataUsingMethod($attributeCode); } else { return $attributeValue; } } } else { $catIds = $product->getCategoryIds(); foreach ($catIds as $catId) { $category = Mage::getModel('catalog/category')->load($catId); if ($category) { //we use the first category return $category->getName(); } } } return false; } /** * retrieve an item's category * if no product attribute chosen use the product's first category * * @param $item * * @return mixed|null */ protected function getCategory($item) { $product = Mage::getModel('catalog/product')->load($item->getProductId()); if ($product) { return $this->getProductCategory($product); } return null; } /** * Return REQUEST_URI for current page * Magento default analytics reports can include the same page as * /checkout/onepage/index/ and /checkout/onepage/ * filter out index/ here and unify to no trailing / * * @return string */ public function getPageName() { if (!$this->hasData('page_name')) { $parts = parse_url( Mage::getSingleton('core/url')->escape( Mage::app()->getRequest()->getServer('REQUEST_URI') ) ); $query = ''; if (isset($parts['query']) && !empty($parts['query'])) { $query = '?' . $parts['query']; } $url = Mage::getSingleton('core/url')->escape( rtrim( str_replace( 'index/', '', Mage::app()->getRequest()->getBaseUrl() . Mage::app()->getRequest()->getRequestString() ), '/' ). $query ); $this->setPageName($url); } return $this->getData('page_name'); } public function getBasePageName() { return Mage::getSingleton('core/url')->escape( rtrim( str_replace( 'index/', '', Mage::app()->getRequest()->getBaseUrl() . Mage::app()->getRequest()->getRequestString() ), '/' ) ); } public function getPageQuery() { $parts = parse_url($this->getPageName()); $query = ''; if (isset($parts['query']) && !empty($parts['query'])) { $query = '?' . $parts['query']; } return $query; } /** * get Google Analytics profile id * * @return mixed|string */ public function getMainAccountId() { if (!Mage::helper('googleanalytics')->isGoogleAnalyticsAvailable()) { return ''; } return Mage::getStoreConfig(Mage_GoogleAnalytics_Helper_Data::XML_PATH_ACCOUNT); } /** * get alternative Google Analytics profile id * * @return mixed */ public function getAlternativeAccountId() { return Mage::getStoreConfig('google/analyticsplus_classic/accountnumber2'); } /** * get Google Analytics universal account id * * @return mixed */ public function getUniversalAccount() { return Mage::getStoreConfig('google/analyticsplus_universal/accountnumber'); } /** * get Google Analytics universal account id for alternative profile * * @return mixed */ public function getAlternativeUniversalAccount() { return Mage::getStoreConfig('google/analyticsplus_universal/altaccountnumber'); } /** * are we using universal * * @return bool */ public function isUniversalEnabled() { return Mage::getStoreConfigFlag('google/analyticsplus_universal/enabled'); } /** * are we using tag manager * * @return bool */ public function isTagManagerEnabled() { return Mage::getStoreConfigFlag('google/analyticsplus_tagmanager/enabled'); } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/TagManager.php 0000666 00000002206 13066147041 0021210 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Block_TagManager extends Fooman_GoogleAnalyticsPlus_Block_Common_Abstract { protected function _construct() { parent::_construct(); $this->setTemplate('fooman/googleanalyticsplus/tagmanager.phtml'); } /** * should we include the tag manager snippet * * @return bool */ public function shouldInclude() { if (parent::shouldInclude()) { return $this->isTagManagerEnabled() && (bool)$this->getTagManagerSnippet(); } else { return false; } } /** * get tag manager snippet from settings * * @return string */ public function getTagManagerSnippet() { return Mage::getStoreConfig('google/analyticsplus_tagmanager/snippet'); } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/Ajax.php 0000666 00000001140 13066147041 0020061 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Block_Ajax extends Fooman_GoogleAnalyticsPlus_Block_Common_Abstract { protected function _construct() { parent::_construct(); $this->setTemplate('fooman/googleanalyticsplus/ajax-tracking.phtml'); } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/Remarketing.php 0000666 00000022335 13066147041 0021457 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Block_Remarketing extends Fooman_GoogleAnalyticsPlus_Block_GaConversion { const GA_PAGETYPE_HOME = 'home'; const GA_PAGETYPE_SEARCHRESULTS = 'searchresults'; const GA_PAGETYPE_CATEGORY = 'category'; const GA_PAGETYPE_PRODUCT = 'product'; const GA_PAGETYPE_CART = 'cart'; const GA_PAGETYPE_PURCHASE = 'purchase'; const GA_PAGETYPE_OTHER = 'other'; protected $_pageType = null; protected function _construct() { parent::_construct(); $this->setTemplate('fooman/googleanalyticsplus/remarketing.phtml'); } /** * are we using dynamic remarketing * * @return bool */ public function shouldInclude() { if (parent::shouldInclude()) { return Mage::getStoreConfigFlag('google/analyticsplus_dynremarketing/enabled') && $this->getConversionId(); } else { return false; } } /** * get no script url for remarketing tracking * * @return string */ public function getNoScriptConversionUrl() { if ($this->getConversionLabel()) { $url = sprintf( "//googleads.g.doubleclick.net/pagead/viewthroughconversion/%s/?value=0&label=%s&guid=ON&script=0", $this->getConversionId(), $this->getConversionLabel() ); } else { $url = sprintf( "//googleads.g.doubleclick.net/pagead/viewthroughconversion/%s/?value=0&guid=ON&script=0", $this->getConversionId() ); } return $url; } /** * product category for product page * * @return string */ public function getEcommCategory() { if ($this->getPageType() == self::GA_PAGETYPE_PRODUCT) { return parent::getProductCategory(Mage::registry('current_product')); } return false; } /** * value of product for product page * * @return string */ public function getEcommPValue() { if ($this->getPageType() == self::GA_PAGETYPE_PRODUCT) { return sprintf( "%01.2f", Mage::helper('googleanalyticsplus')->convert( Mage::registry('current_product'), 'final_price', Mage::app()->getStore()->getCurrentCurrencyCode() ) ); } } /** * get value for current page, if order present use it's subtotal * otherwise use current quote * * @return string */ public function getPageValue() { $values = array(); switch ($this->getPageType()) { case self::GA_PAGETYPE_PRODUCT: return $this->getEcommPValue(); break; case self::GA_PAGETYPE_CART: $quote = Mage::getSingleton('checkout/session')->getQuote(); if (count($quote->getAllVisibleItems())) { foreach ($quote->getAllVisibleItems() as $basketItem) { $values[] = sprintf( '%01.2f', Mage::helper('googleanalyticsplus')->convert($basketItem, 'row_total') ); } } return $this->getArrayReturnValue($values, '0.00'); break; case self::GA_PAGETYPE_PURCHASE: if ($this->_getOrder()) { foreach ($this->_getOrder()->getAllVisibleItems() as $orderItem) { $values[] = sprintf( '%01.2f', Mage::helper('googleanalyticsplus')->convert($orderItem, 'row_total') ); } } return $this->getArrayReturnValue($values, '0.00'); } return "''"; } /** * get list of product ids for current page * * @return string */ public function getProdId() { $products = array(); switch ($this->getPageType()) { case self::GA_PAGETYPE_PRODUCT: $products[] = $this->getConfiguredFeedId(Mage::registry('current_product')); return $this->getArrayReturnValue($products, "''"); break; case self::GA_PAGETYPE_CART: $quote = Mage::getSingleton('checkout/session')->getQuote(); if ($quote) { foreach ($quote->getAllItems() as $item) { $products[] = $this->getConfiguredFeedId($item->getProduct()); } } return $this->getArrayReturnValue($products, "''", true); break; case self::GA_PAGETYPE_PURCHASE: if ($this->_getOrder()) { foreach ($this->_getOrder()->getAllItems() as $item) { $products[] = $this->getConfiguredFeedId($item->getProduct()); } } return $this->getArrayReturnValue($products, "''", true); break; } return "''"; } /** * @param Mage_Catalog_Model_Product $product * @return string|integer */ public function getConfiguredFeedId ($product) { $idAttr = Mage::getStoreConfig('google/analyticsplus_dynremarketing/feed_product_id'); $id = $product->getDataUsingMethod($idAttr); return $id; } /** * determine current page type for dynamic remarketing * * @return null|string */ public function getPageType() { if (is_null($this->_pageType)) { if (Mage::registry('current_product')) { $this->_pageType = self::GA_PAGETYPE_PRODUCT; return $this->_pageType; } if (Mage::registry('current_category')) { $this->_pageType = self::GA_PAGETYPE_CATEGORY; return $this->_pageType; } $module = Mage::app()->getRequest()->getModuleName(); $controller = Mage::app()->getRequest()->getControllerName(); $action = Mage::app()->getRequest()->getActionName(); switch ($module) { case 'cms': if ($controller == 'index' && $action == 'index') { $this->_pageType = self::GA_PAGETYPE_HOME; } else { $this->_pageType = self::GA_PAGETYPE_OTHER; } break; case 'checkout': if ($controller == 'cart') { $this->_pageType = self::GA_PAGETYPE_CART; } elseif ($action == 'success') { $this->_pageType = self::GA_PAGETYPE_PURCHASE; } else { $this->_pageType = self::GA_PAGETYPE_OTHER; } break; case 'catalogsearch': if ($controller == 'result') { $this->_pageType = self::GA_PAGETYPE_SEARCHRESULTS; } else { $this->_pageType = self::GA_PAGETYPE_OTHER; } break; default: $this->_pageType = self::GA_PAGETYPE_OTHER; } } return $this->_pageType; } /** * get Adword's conversion label from settings * can't be chosen freely since assigned from Google * * @return string */ public function getConversionLabel() { return Mage::getStoreConfig('google/analyticsplus_dynremarketing/conversionlabel'); } /** * get Google Adwords conversion id * * @return string */ public function getConversionId() { return Mage::getStoreConfig('google/analyticsplus_dynremarketing/conversionid'); } /** * utility function to convert array of values as single or multiple value notation * * @param $values * @param string $default * @param bool $sort * * @return string */ public function getArrayReturnValue($values, $default = '', $sort = false) { if (empty($values)) { return $default; } if ($sort) { asort($values); } array_walk($values, array($this, 'prepareValue')); reset($values); if (sizeof($values) == 1) { return current($values); } else { return '[' . implode(',', $values) . ']'; } } /** * escape all quotes and additionally quote all strings * @param $value * * @return mixed|string */ public function prepareValue(&$value) { $value = $this->jsQuoteEscape($value); // quote if value is not numeric if (!ctype_digit($value)) { $value = "'$value'"; } return $value; } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/Adminhtml/Extensioninfo.php 0000666 00000000421 13066147041 0023744 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Block_Universal extends Fooman_GoogleAnalyticsPlus_Block_GaConversion { const TRACKER_TWO_NAME = 'tracker2'; CONST URL_ANALYTICS = '//www.google-analytics.com/analytics.js'; CONST URL_ANALYTICS_DEBUG = '//www.google-analytics.com/analytics_debug.js'; protected function _construct() { parent::_construct(); $this->setTemplate('fooman/googleanalyticsplus/universal.phtml'); } /** * should we include the universal snippet * * @return bool */ public function shouldInclude() { if (parent::shouldInclude()) { return $this->isUniversalEnabled() && (bool)$this->getUniversalAccount(); } else { return false; } } /** * @return bool */ public function getUniversalAnonymise() { return Mage::getStoreConfigFlag('google/analyticsplus_universal/anonymise'); } /** * Build any params that is passed on create of analytics object * * @param bool $createTrackerTwo * * @return string */ public function getUniversalParams($createTrackerTwo = false) { $params = array(); if (Mage::getStoreConfig('google/analyticsplus_universal/domainname')) { $params['cookieDomain'] = Mage::getStoreConfig('google/analyticsplus_universal/domainname'); } if ($this->canUseUniversalUserTracking()) { $params['userId'] = $this->getCustomerId(); } if ($createTrackerTwo) { $params['name'] = self::TRACKER_TWO_NAME; } if (count($params) == 0) { return "'auto'"; } return json_encode($params); } /** * Enable the Display Advertising Features. * * @return bool */ public function getUniversalDisplayAdvertising() { return Mage::getStoreConfigFlag('google/analyticsplus_universal/display_advertising'); } /** * Return cookiename for Display Advertising * * @return String */ public function getUniversalDisplayAdvertisingCookieName() { return Mage::getStoreConfig('google/analyticsplus_universal/display_advertising_cookiename'); } /** * Is universal user tracking available. * Must be enabled in admin and a user must be logged in * TODO: Use persistent login data! * * @return bool */ public function canUseUniversalUserTracking() { return (Mage::getStoreConfigFlag('google/analyticsplus_universal/userid_tracking') && Mage::getSingleton( 'customer/session' )->isLoggedIn()) ? true : false; } /** * Get the current logged in customer id * * @return mixed bool | integer */ public function getCustomerId() { if (Mage::getSingleton('customer/session')->isLoggedIn() && is_object( Mage::getSingleton('customer/session')->getCustomer() ) ) { return Mage::getSingleton('customer/session')->getCustomer()->getId(); } return false; } /** * Get the right analytics.js * * @return string */ public function getAnalyticsLocation() { $debug = Mage::getStoreConfigFlag('google/analyticsplus_universal/debug'); if ($debug) { return self::URL_ANALYTICS_DEBUG; } return self::URL_ANALYTICS; } /** * Get the exclude shipping settings * * @return bool */ public function shouldExcludeShipping() { return Mage::getStoreConfigFlag('google/analyticsplus_universal/exclude_shipping'); } /** * Get the exclude Tax Settings.... * * @return bool */ public function shouldExcludeTax() { return Mage::getStoreConfigFlag('google/analyticsplus_universal/exclude_tax'); } } app/code/community/Fooman/GoogleAnalyticsPlus/LICENSE.txt 0000666 00000024173 13066147041 0017271 0 ustar 00 Open Software License ("OSL") v. 3.0 This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: Licensed under the Open Software License version 3.0 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: 1. to reproduce the Original Work in copies, either alone or as part of a collective work; 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; 4. to perform the Original Work publicly; and 5. to display the Original Work publicly. 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. app/code/community/Fooman/GoogleAnalyticsPlus/etc/system.xml 0000666 00000045475 13066147041 0020277 0 ustar 00 GoogleAnalyticsPlus label googleanalyticsplus/adminhtml_extensioninfo 10 1 1 1 GoogleAnalyticsPlus by Fooman text 11 1 1 1 For detailed instructions please refer to the Google Analytics + User Manual here. ]]> Convert Currency select adminhtml/system_config_source_yesno 560 1 0 0 Currency select adminhtml/system_config_source_currency 570 1 0 0 1 Category Tracking Attribute If none selected then first category name will be used select googleanalyticsplus/source_productattribute 580 1 1 1 Google Adwords Conversion by Fooman 12 1 1 1 Enable Adwords Conversion Tracking select adminhtml/system_config_source_yesno 500 1 1 1 Conversion ID text 520 1 1 1 1 Conversion Language select googleanalyticsplus/system_language 540 1 1 1 1 Conversion Label text 550 1 1 1 1 Debug select adminhtml/system_config_source_yesno 560 1 1 1 Google Universal Analytics by Fooman 13 1 1 1 Enabled select adminhtml/system_config_source_yesno 10 1 1 1 Account Number text 100 1 1 1 Account Number (alternative Profile) text 150 1 1 1 Anonymise IP Address Google Documentation for details]]> select adminhtml/system_config_source_yesno 200 1 1 1 Cookie Domain Name Google Documentation]]> text 300 1 1 1 Enable Display Advertising Features Google Documentation for details]]> select adminhtml/system_config_source_yesno 400 1 1 1 Display Advertising Features Cookie Name Google Documentation]]> text 401 1 1 1 1 Enable User ID Feature Google Documentation for details]]> select adminhtml/system_config_source_yesno 500 1 1 1 Exclude Shipping from Conversion Total select adminhtml/system_config_source_yesno 502 1 1 1 Exclude Tax from Conversion Total select adminhtml/system_config_source_yesno 504 1 1 1 Debug select adminhtml/system_config_source_yesno 510 1 1 1 Google Tag Manager by Fooman 14 1 1 1 Enabled select adminhtml/system_config_source_yesno 10 1 1 1 Container Snippet textarea 20 1 1 1 1 Google Dynamic Remarketing by Fooman 15 1 1 1 Enabled select adminhtml/system_config_source_yesno 10 1 1 1 Conversion ID text 20 1 1 1 1 Conversion Label text 30 1 1 1 1 Product ID in Merchants Feed select googleanalyticsplus/source_productattribute 40 1 1 1 1 app/code/community/Fooman/GoogleAnalyticsPlus/etc/config.xml 0000666 00000006766 13066147041 0020220 0 ustar 00 0.16.8 Fooman_GoogleAnalyticsPlus_Model Fooman_GoogleAnalyticsPlus_Helper Fooman_GoogleAnalyticsPlus_Block Fooman_GoogleAnalyticsPlus googleanalyticsplus.xml googleanalyticsplus/observer addCheckoutStepTracking googleanalyticsplus/observer setOrder googleanalyticsplus/observer setOrder 0 en 0 entity_id 0 community/Fooman/GoogleAnalyticsPlus/sql/googleanalyticsplus_setup/mysql4-upgrade-0.14.1-0.14.2.php 0000666 00000001320 13066147041 0030311 0 ustar 00 app/code startSetup(); //migrate old config values to new paths $oldToNewMap = array( 'domainname'=>'domainname', 'accountnumber2'=>'accountnumber2', 'domainname2'=>'domainname2', 'anonymise'=>'anonymise', 'remarketing'=>'remarketing', 'conversionenabled'=>'conversionenabled', 'conversionid'=>'conversionid', 'conversionlanguage'=>'conversionlanguage', 'conversionlabel'=>'conversionlabel' ); foreach ($oldToNewMap as $old => $new) { $installer->run( "UPDATE IGNORE {$this->getTable('core_config_data')} SET `path`='google/analyticsplus_classic/{$new}' WHERE `path`='google/analyticsplus/{$old}';" ); } $installer->endSetup(); app/code/community/Fooman/GoogleAnalyticsPlus/sql/googleanalyticsplus_setup/mysql4-install-0.0.1.php0000666 00000000115 13066147041 0027603 0 ustar 00 startSetup(); $installer->endSetup(); app/code/community/Fooman/GoogleAnalyticsPlus/modman 0000666 00000001077 13066147041 0016642 0 ustar 00 ../../../../../app/code/community/Fooman/GoogleAnalyticsPlus/ /app/code/community/Fooman/GoogleAnalyticsPlus/ ../../../../../app/design/frontend/base/default/layout/googleanalyticsplus.xml /app/design/frontend/base/default/layout/googleanalyticsplus.xml ../../../../../app/design/frontend/base/default/template/fooman/googleanalyticsplus/ /app/design/frontend/base/default/template/fooman/googleanalyticsplus/ ../../../../../app/etc/modules/Fooman_GoogleAnalyticsPlus.xml /app/etc/modules/Fooman_GoogleAnalyticsPlus.xml app/code/community/Fooman/GoogleAnalyticsPlus/Model/Source/Productattribute.php 0000666 00000002145 13066147041 0024016 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Model_Source_Productattribute { public function toOptionArray() { $options = array(); $collection = Mage::getResourceModel('catalog/product_attribute_collection'); $options[] = array( 'value' => '', 'label' => '' ); $options[] = array( 'value' => 'entity_id', 'label' => 'Entity Id' ); foreach ($collection as $attribute) { $options[] = array( 'value' => $attribute->getAttributeCode(), 'label' => ($attribute->getFrontendLabel() ? $attribute->getFrontendLabel() : $attribute->getAttributeCode()) ); } return $options; } } app/code/community/Fooman/GoogleAnalyticsPlus/Model/System/Language.php 0000666 00000011142 13066147041 0022216 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Model_System_Language { public function toOptionArray() { $returnArray[] = array('value' => 'en', 'label' => Mage::helper('directory')->__('English')); $returnArray[] = array('value' => 'de', 'label' => Mage::helper('directory')->__('German')); $returnArray[] = array('value' => 'fr', 'label' => Mage::helper('directory')->__('French')); $returnArray[] = array('value' => 'es', 'label' => Mage::helper('directory')->__('Spanish')); $returnArray[] = array('value' => 'it', 'label' => Mage::helper('directory')->__('Italian')); $returnArray[] = array('value' => 'ja', 'label' => Mage::helper('directory')->__('Japanese')); $returnArray[] = array('value' => 'da', 'label' => Mage::helper('directory')->__('Danish')); $returnArray[] = array('value' => 'nl', 'label' => Mage::helper('directory')->__('Dutch')); $returnArray[] = array('value' => 'fi', 'label' => Mage::helper('directory')->__('Finnish')); $returnArray[] = array('value' => 'ko', 'label' => Mage::helper('directory')->__('Korean')); $returnArray[] = array('value' => 'no', 'label' => Mage::helper('directory')->__('Norwegian')); $returnArray[] = array('value' => 'pt', 'label' => Mage::helper('directory')->__('Portuguese')); $returnArray[] = array('value' => 'sv', 'label' => Mage::helper('directory')->__('Swedish')); $returnArray[] = array('value' => 'zh_CN', 'label' => Mage::helper('directory')->__('Chinese (simplified)')); $returnArray[] = array('value' => 'zh_TW', 'label' => Mage::helper('directory')->__('Chinese (traditional)')); $returnArray[] = array('value' => 'ar', 'label' => Mage::helper('directory')->__('Arabic')); $returnArray[] = array('value' => 'bg', 'label' => Mage::helper('directory')->__('Bulgarian')); $returnArray[] = array('value' => 'cs', 'label' => Mage::helper('directory')->__('Czech')); $returnArray[] = array('value' => 'el', 'label' => Mage::helper('directory')->__('Greek')); $returnArray[] = array('value' => 'hi', 'label' => Mage::helper('directory')->__('Hindi')); $returnArray[] = array('value' => 'hu', 'label' => Mage::helper('directory')->__('Hungarian')); $returnArray[] = array('value' => 'id', 'label' => Mage::helper('directory')->__('Indonesian')); $returnArray[] = array('value' => 'is', 'label' => Mage::helper('directory')->__('Icelandic')); $returnArray[] = array('value' => 'iw', 'label' => Mage::helper('directory')->__('Hebrew')); $returnArray[] = array('value' => 'lv', 'label' => Mage::helper('directory')->__('Latvian')); $returnArray[] = array('value' => 'lt', 'label' => Mage::helper('directory')->__('Lithuanian')); $returnArray[] = array('value' => 'pl', 'label' => Mage::helper('directory')->__('Polish')); $returnArray[] = array('value' => 'ru', 'label' => Mage::helper('directory')->__('Russian')); $returnArray[] = array('value' => 'ro', 'label' => Mage::helper('directory')->__('Romanian')); $returnArray[] = array('value' => 'sk', 'label' => Mage::helper('directory')->__('Slovak')); $returnArray[] = array('value' => 'sl', 'label' => Mage::helper('directory')->__('Slovenian')); $returnArray[] = array('value' => 'sr', 'label' => Mage::helper('directory')->__('Serbian')); $returnArray[] = array('value' => 'uk', 'label' => Mage::helper('directory')->__('Ukrainian')); $returnArray[] = array('value' => 'tr', 'label' => Mage::helper('directory')->__('Turkish')); $returnArray[] = array('value' => 'ca', 'label' => Mage::helper('directory')->__('Catalan')); $returnArray[] = array('value' => 'hr', 'label' => Mage::helper('directory')->__('Croatian')); $returnArray[] = array('value' => 'vi', 'label' => Mage::helper('directory')->__('Vietnamese')); $returnArray[] = array('value' => 'ur', 'label' => Mage::helper('directory')->__('Urdu')); $returnArray[] = array('value' => 'tl', 'label' => Mage::helper('directory')->__('Filipino')); $returnArray[] = array('value' => 'et', 'label' => Mage::helper('directory')->__('Estonian')); $returnArray[] = array('value' => 'th', 'label' => Mage::helper('directory')->__('Thai')); return $returnArray; } } app/code/community/Fooman/GoogleAnalyticsPlus/Model/Observer.php 0000666 00000001262 13066147041 0021000 0 ustar 00 getEvent()->getBlock(); $transport = $observer->getEvent()->getTransport(); if ($block instanceof Mage_Checkout_Block_Onepage_Billing) { $origBlockContent = $transport->getHtml(); $trackingJs = $block->getLayout()->createBlock('googleanalyticsplus/ajax')->toHtml(); $transport->setHtml($trackingJs . $origBlockContent); } } public function setOrder($observer) { Mage::register('googleanalyticsplus_order_ids', $observer->getEvent()->getOrderIds(), true); } } app/code/community/Fooman/GoogleAnalyticsPlus/Model/Selftester.php 0000666 00000005070 13066147041 0021332 0 ustar 00 %s', self::MANUAL_URL, 'Please read the manual for details.'); } public function _getFiles() { //REPLACE return array( 'app/etc/modules/Fooman_GoogleAnalyticsPlus.xml', 'app/code/community/Fooman/GoogleAnalyticsPlus/Helper/Data.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/etc/system.xml', 'app/code/community/Fooman/GoogleAnalyticsPlus/etc/config.xml', 'app/code/community/Fooman/GoogleAnalyticsPlus/Block/Universal.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Block/Remarketing.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Block/TagManager.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Block/GaConversion.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Block/Adminhtml/Extensioninfo.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Block/Ajax.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/LICENSE.txt', 'app/code/community/Fooman/GoogleAnalyticsPlus/Model/Backend/Accountnumber.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Model/Selftester.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Model/Source/Productattribute.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Model/Observer.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/Model/System/Language.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/sql/googleanalyticsplus_setup/mysql4-install-0.0.1.php', 'app/code/community/Fooman/GoogleAnalyticsPlus/sql/googleanalyticsplus_setup/mysql4-upgrade-0.14.1-0.14.2.php', 'app/design/frontend/base/default/layout/googleanalyticsplus.xml', 'app/design/frontend/base/default/template/fooman/googleanalyticsplus/universal.phtml', 'app/design/frontend/base/default/template/fooman/googleanalyticsplus/ajax-tracking.phtml', 'app/design/frontend/base/default/template/fooman/googleanalyticsplus/ga-conversion.phtml', 'app/design/frontend/base/default/template/fooman/googleanalyticsplus/remarketing.phtml', 'app/design/frontend/base/default/template/fooman/googleanalyticsplus/tagmanager.phtml', ); //REPLACE_END } } app/code/community/Fooman/GoogleAnalyticsPlus/Model/Backend/Accountnumber.php 0000666 00000002140 13066147041 0023341 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Model_Backend_Accountnumber extends Mage_Core_Model_Config_Data { protected function _beforeSave() { $data = $this->getData(); $analyticsAccount = $data['groups']['analytics']['fields']['account']['value']; $analyticsPlusAccount = $data['groups']['analyticsplus_classic']['fields']['accountnumber2']['value']; if (!empty($analyticsPlusAccount) && !empty($analyticsAccount) && $analyticsAccount == $analyticsPlusAccount) { throw Mage::exception( 'Mage_Core', Mage::helper('adminhtml')->__( 'Your alternative account number needs to be different to your existing account number.' ) ); } return true; } } app/code/community/Fooman/GoogleAnalyticsPlus/Helper/Data.php 0000666 00000004667 13066147041 0020255 0 ustar 00 * @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Fooman_GoogleAnalyticsPlus_Helper_Data extends Mage_Core_Helper_Abstract { /** * retrieve requested value from order or item * convert from base currency if configured * else return order currency * * @param $object * @param $field * * @param $currentCurrency * * @return string */ public function convert($object, $field, $currentCurrency = null) { $baseCur = Mage::app()->getStore($object->getStoreId())->getBaseCurrency(); //getPrice and getFinalPrice do not have base equivalents if ($field != 'price' && $field != 'final_price') { $field = 'base_' . $field; $baseValue = $object->getDataUsingMethod($field); } else { if (null === $currentCurrency) { Mage::throwException('Currency needs to be defined'); } $value = $object->getDataUsingMethod($field); if ($currentCurrency == $baseCur->getCode()) { $baseValue = $value; } else { $rate = Mage::getModel('directory/currency') ->load($baseCur->getCode()) ->getRate($currentCurrency); $baseValue = Mage::app()->getStore()->roundPrice($value / $rate); } } if (!Mage::getStoreConfig('google/analyticsplus/convertcurrencyenabled')) { return $baseValue; } return sprintf( "%01.4f", Mage::app()->getStore()->roundPrice( $baseCur->convert( $baseValue, Mage::getStoreConfig('google/analyticsplus/convertcurrency') ) ) ); } /** * currency for tracking * * @param $object * * @return string */ public function getTrackingCurrency($object) { if (!Mage::getStoreConfig('google/analyticsplus/convertcurrencyenabled')) { return $object->getBaseCurrencyCode(); } else { return Mage::getStoreConfig('google/analyticsplus/convertcurrency'); } } } app/design/frontend/base/default/template/fooman/googleanalyticsplus/ajax-tracking.phtml 0000666 00000004255 13066147041 0025741 0 ustar 00 app/design/frontend/base/default/template/fooman/googleanalyticsplus/tagmanager.phtml 0000666 00000000411 13066147041 0025312 0 ustar 00 shouldInclude()): ?> getTagManagerSnippet(); ?> app/design/frontend/base/default/template/fooman/googleanalyticsplus/ga-conversion.phtml 0000666 00000001577 13066147041 0025774 0 ustar 00 isEnabled()):?> app/design/frontend/base/default/template/fooman/googleanalyticsplus/universal.phtml 0000666 00000011476 13066147041 0025231 0 ustar 00 shouldInclude()): ?> getAlternativeUniversalAccount(); ?> isSuccessPage()):?> _getOrder();?> app/design/frontend/base/default/template/fooman/googleanalyticsplus/remarketing.phtml 0000666 00000003121 13066147041 0025515 0 ustar 00 shouldInclude()): ?> getPageValue(); $prodId = $this->getProdId(); $pageType = $this->getPageType(); $conversionLabel = $this->getConversionLabel(); $conversionId = $this->getConversionId(); ?> app/design/frontend/base/default/layout/googleanalyticsplus.xml 0000666 00000004507 13066147041 0021115 0 ustar 00 google_analytics google_analytics google_analytics README.md 0000666 00000003775 13066147041 0006045 0 ustar 00 Fooman Google Analytics+ =================== Magento Extension to add extra features to the default GoogleAnalytics module. ### Extra features compared to the version available on Magento Connect - Works on Magento 1.8.1 - Dropped Support for Magento pre 1.4.2 - Google Universal Support with Ecommerce Tracking - Dynamic Remarketing (add your conversion id and label as provided from Google, products are identified by their product id) - Tag Manager (this provides an input field for the tag manager script snippet - please note that the population of the data layer would be up to you) - Category for transaction items is now populated (based on custom attribute, otherwise defaults to first encountered product category) - more templates To provide feedback please create an issue on Github. ### User Manual The user manual can be downloaded from [here](http://store.fooman.co.nz/to/GoogleAnalyticsPlus/manual) ### Installation Instructions To install the extension, follow the steps in [The Ultimate Guide to Installing Magento Extensions](http://cdn.fooman.co.nz/media/custom/upload/TheUltimateGuidetoInstallingMagentoExtensions.pdf). ### Installation Options **via composer** Fooman extension are included in the packages.firegento.com repository so you can install them easily via adding the extension to the require section and then running `composer install` or `composer update` "require":{ "fooman/googleanalyticsplus":"*" }, Please note that packages.firegento.com is not always up-to-date - in this case please add the following in the repositories section "repositories":[ { "type":"composer", "url":"http://packages.fooman.co.nz" } ], **via modman** `modman clone https://github.com/fooman/common.git` `modman clone https://github.com/fooman/googleanalyticsplus.git` **via file transfer (zip download)** please see the releases tab for https://github.com/fooman/googleanalyticsplus/releases and https://github.com/fooman/common/releases
For detailed instructions please refer to the Google Analytics + User Manual here.