composer.json 0000666 00000002323 13066146442 0007300 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": "*" }, "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 00000000067 13066146442 0005757 0 ustar 00 @import app/code/community/Fooman/GoogleAnalyticsPlus/ app/etc/modules/Fooman_GoogleAnalyticsPlus.xml 0000666 00000000463 13066146442 0015535 0 ustar 00 true community app/code/community/Fooman/GoogleAnalyticsPlus/Block/GaConversion.php 0000666 00000006240 13066146443 0021606 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 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) { $quoteId = Mage::getSingleton('checkout/session')->getLastQuoteId(); if ($quoteId) { $this->_order = Mage::getModel('sales/order')->loadByAttribute('quote_id', $quoteId); } 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 00000007054 13066146443 0022210 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(); return in_array('checkout_onepage_success', $handles) || in_array('checkout_multishipping_success', $handles); } /** * 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'); } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/Ga.php 0000666 00000027317 13066146443 0017550 0 ustar 00 * @author Fooman, Kristof Ringleff */ class Fooman_GoogleAnalyticsPlus_Block_Ga extends Fooman_GoogleAnalyticsPlus_Block_Common_Abstract { const URL_GA_STANDARD = 'http://www.google-analytics.com/ga.js'; const URL_GA_STANDARD_SECURE = 'https://ssl.google-analytics.com/ga.js'; const URL_DOUBLECLICK = 'http://stats.g.doubleclick.net/dc.js'; const URL_DOUBLECLICK_SECURE = 'https://stats.g.doubleclick.net/dc.js'; protected $_helper; protected function _construct() { parent::_construct(); $this->setTemplate('fooman/googleanalyticsplus/ga.phtml'); $this->_helper = Mage::helper('googleanalyticsplus'); } /** * get the current url to send to Google Analytics * * @return string */ public function getUrlToTrack() { $optPageURL = trim($this->getPageName()); if ($optPageURL && preg_match('/^\/.*/i', $optPageURL)) { $optPageURL = "{$this->jsQuoteEscape($optPageURL)}"; } return $optPageURL; } /** * things have change in Magento 1.4.2 * * @return bool */ public function isNew() { //Mage 1.4.2 + return method_exists(Mage::helper('googleanalytics'), 'isGoogleAnalyticsAvailable'); } /** * 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'); } /** * should we include tracking code * if cookies have not been accepted - do no track * * @return bool */ public function shouldIncludeTracking() { $coreHelperDir = Mage::getConfig()->getModuleDir('', 'Mage_Core') . DS . 'Helper' . DS; if (file_exists($coreHelperDir . 'Cookie.php')) { if (Mage::helper('core/cookie')->isUserNotAllowSaveCookie()) { return false; } } return (bool)$this->getMainAccountId(); } /** * which GA script are we using? * * @return string */ public function getGaLocation() { $secure = Mage::app()->getStore()->isCurrentlySecure() ? 'true' : 'false'; if ($secure == 'true') { if (Mage::getStoreConfig('google/analyticsplus_classic/remarketing')) { return self::URL_DOUBLECLICK_SECURE; } else { return self::URL_GA_STANDARD_SECURE; } } else { if (Mage::getStoreConfig('google/analyticsplus_classic/remarketing')) { return self::URL_DOUBLECLICK; } else { return self::URL_GA_STANDARD; } } } /** * determine if we are on the order success page * * @return bool */ public function isSuccessPage() { $handles = $this->getLayout()->getUpdate()->getHandles(); $orderIds = $this->getOrderIds(); return in_array('checkout_onepage_success', $handles) || in_array('checkout_multishipping_success', $handles) || (!empty($orderIds) && is_array($orderIds)); } /** * Render information about specified orders and their items * * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans * * @param bool $accountIdAlt * * @return string */ public function getOrdersTrackingCode($accountIdAlt = false) { $html = ''; $orderIds = $this->getOrderIds(); if (empty($orderIds) || !is_array($orderIds)) { return $html; } $collection = Mage::getResourceModel('sales/order_collection') ->addFieldToFilter('entity_id', array('in' => $orderIds)); $result = array(); foreach ($collection as $order) { if ($order->getIsVirtual()) { $address = $order->getBillingAddress(); } else { $address = $order->getShippingAddress(); } $result[] = sprintf( "_gaq.push(['_addTrans', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s']);", $order->getIncrementId(), $this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName()), Mage::helper('googleanalyticsplus')->convert($order, 'grand_total'), Mage::helper('googleanalyticsplus')->convert($order, 'tax_amount'), Mage::helper('googleanalyticsplus')->convert($order, 'shipping_amount'), $this->jsQuoteEscape($address->getCity()), $this->jsQuoteEscape($address->getRegion()), $this->jsQuoteEscape($address->getCountry()) ); foreach ($order->getAllVisibleItems() as $item) { $result[] = sprintf( "_gaq.push(['_addItem', '%s', '%s', '%s', '%s', '%s', '%s']);", $order->getIncrementId(), $this->jsQuoteEscape($item->getSku()), $this->jsQuoteEscape($item->getName()), $this->jsQuoteEscape($this->getCategory($item)), Mage::helper('googleanalyticsplus')->convert($item, 'price'), (int)$item->getQtyOrdered() ); } $result[] = "_gaq.push(['_trackTrans']);"; $html = implode("\n", $result); } if ($accountIdAlt) { $html .= str_replace('_gaq.push([\'_', '_gaq.push([\'t2._', $html); } return $html; } /** * set CustomVars for customers * * @param bool $accountIdAlt * * @return string */ public function getCustomerVars($accountIdAlt = false) { //set customer variable for the current visitor c=1 return " _gaq.push(['_setCustomVar', 5, 'c', '1', 1]); " . ($accountIdAlt ? "_gaq.push(['t2._setCustomVar', 5, 'c', '1', 1]);" : ""); } /** * @param $accountId * @param bool|int $accountIdAlt * * @return string */ public function getPageTrackingCode($accountId, $accountIdAlt = false) { //url to track $optPageURL = $this->getUrlToTrack(); //main profile tracking $html= "_gaq.push(['_setAccount', '" . $this->jsQuoteEscape($accountId) . "']"; if ($domainName = Mage::getStoreConfig('google/analyticsplus_classic/domainname')) { $html .= " ,['_setDomainName','" . $domainName . "']"; } //anonymise $anonymise = Mage::getStoreConfigFlag('google/analyticsplus_classic/anonymise'); if ($anonymise) { $html .= ", ['_gat._anonymizeIp']"; } //send track page view $html .= ", ['_trackPageview','" . $optPageURL . "']"; $html .= ");"; //track to alternative profile (optional) if ($accountIdAlt) { $html .= $this->getPageTrackingAlt($accountIdAlt, $optPageURL); } return $html; } /** * get tracking code for alternative profile * * @param $accountIdAlt * @param $optPageURL * * @return string */ public function getPageTrackingAlt($accountIdAlt, $optPageURL) { $html = " _gaq.push(['t2._setAccount', '" . $this->jsQuoteEscape($accountIdAlt) . "']"; $domainNameAlt = Mage::getStoreConfig('google/analyticsplus_classic/domainname2'); if ($domainNameAlt) { $html .= " ,['t2._setDomainName','" . $domainNameAlt . "']"; } $html .= ", ['t2._trackPageview','" . $optPageURL . "']"; $html .= ");"; return $html; } /** * return code to track AJAX requests * * @param bool|int $accountIdAlt * * @return string */ public function getAjaxPageTracking($accountIdAlt = false) { $parts = parse_url($this->getPageName()); $query = ''; if (isset($parts['query']) && !empty($parts['query'])) { $query = '?' . $parts['query']; } unset($parts['query']); unset($parts['fragment']); $baseUrl = Mage::getSingleton('core/url')->escape( rtrim( str_replace( 'index/', '', Mage::app()->getRequest()->getBaseUrl() . Mage::app()->getRequest()->getRequestString() ), '/' ) ); return " if(typeof Ajax !== \"undefined\" && Ajax.Responders){ Ajax.Responders.register({ onComplete: function(transport){ if(!transport.url.include('progress') && !transport.url.include('getAdditional')){ goto_section = false; if (transport && transport.transport.responseText){ try{ response = eval('(' + transport.transport.responseText + ')'); if(response && response.goto_section){ goto_section = '/opc-' + encodeURIComponent(response.goto_section); } } catch (e) { goto_section = false; } } if(transport.url.include('saveOrder')){ _gaq.push(['_trackPageview', '".$baseUrl."' + '/opc-review-placeOrderClicked".$query."']);" .($accountIdAlt?" _gaq.push(['t2._trackPageview', '".$baseUrl."' + '/opc-review-placeOrderClicked".$query."']);":"")." }else if(goto_section){ _gaq.push(['_trackPageview', '".$baseUrl."' + goto_section + '".$query."']);" .($accountIdAlt?" _gaq.push(['t2._trackPageview', '".$baseUrl."' + goto_section + '".$query."']);":"")." }else if(accordion && accordion.currentSection){ _gaq.push(['_trackPageview', '".$baseUrl."/' + accordion.currentSection + '".$query."']);" .($accountIdAlt?" _gaq.push(['t2._trackPageview', '".$baseUrl."/' + accordion.currentSection + '".$query."']);":"")." } } } }); } "; } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/TagManager.php 0000666 00000002534 13066146443 0021221 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; } } /** * are we using tag manager * * @return bool */ public function isTagManagerEnabled() { return Mage::getStoreConfigFlag('google/analyticsplus_tagmanager/enabled'); } /** * get tag manager snippet from settings * * @return string */ public function getTagManagerSnippet() { return Mage::getStoreConfig('google/analyticsplus_tagmanager/snippet'); } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/Remarketing.php 0000666 00000017766 13066146443 0021500 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 = 'siteview'; 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; } } /** * 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') ); } } /** * 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 false; } /** * get list of product ids for current page * * @return string */ public function getProdId() { 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); } } return $this->getArrayReturnValue($products, '', true); break; case self::GA_PAGETYPE_PURCHASE: if ($this->_getOrder()) { foreach ($this->_getOrder()->getAllItems() as $item) { $products[] = $this->getConfiguredFeedId($item); } } return $this->getArrayReturnValue($products, '', true); break; } return false; } /** * @param Mage_Catalog_Model_Product $product * @return string|integer */ public function getConfiguredFeedId ($product) { $idAttr = Mage::getStoreConfig('google/analyticsplus_dynremarketing/feed_product_id'); $id = $product->getData($idAttr); // quote if id is not numeric if (!ctype_digit($id)) { $id = "'$id'"; } 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); } if (sizeof($values) == 1) { return current($values); } else { return '[' . implode(',', $values) . ']'; } } } app/code/community/Fooman/GoogleAnalyticsPlus/Block/Universal.php 0000666 00000005131 13066146443 0021157 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 { 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; } } /** * are we using universal * * @return bool */ public function isUniversalEnabled() { return Mage::getStoreConfigFlag('google/analyticsplus_universal/enabled'); } /** * get universal snippet from settings * * @deprecated since 0.14.0 * @return string */ public function getUniversalSnippet() { return ''; } /** * get Google Analytics account id * * @return mixed */ public function getUniversalAccount() { return Mage::getStoreConfig('google/analyticsplus_universal/accountnumber'); } /** * @return bool */ public function getUniversalAnonymise() { return Mage::getStoreConfigFlag('google/analyticsplus_universal/anonymise'); } /** * @return string */ public function getUniversalParams() { if (Mage::getStoreConfig('google/analyticsplus_universal/domainname')) { return sprintf( "{'cookieDomain': '%s'}", Mage::getStoreConfig('google/analyticsplus_universal/domainname') ); } else { return "'auto'"; } } /** * 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'); } } app/code/community/Fooman/GoogleAnalyticsPlus/LICENSE.txt 0000666 00000024173 13066146443 0017276 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 00000043607 13066146443 0020277 0 ustar 00 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 Classic Analytics by Fooman 12 1 1 1 DomainName Google Documentation]]> text 50 1 1 1 Account Number (alternative Profile) text googleanalyticsplus/backend_accountnumber 100 1 1 1 DomainName (alternative Profile) Google Documentation]]> text 120 1 1 1 Anonymise IP Address Google Documentation for details]]> select adminhtml/system_config_source_yesno 200 1 1 1 Use Google Remarketing Script Google Documentation for details]]> select adminhtml/system_config_source_yesno 200 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 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 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 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 00000003763 13066146443 0020217 0 ustar 00 0.14.9 Fooman_GoogleAnalyticsPlus_Model Fooman_GoogleAnalyticsPlus_Helper Fooman_GoogleAnalyticsPlus_Block Fooman_GoogleAnalyticsPlus googleanalyticsplus.xml 0 0 en entity_id community/Fooman/GoogleAnalyticsPlus/sql/googleanalyticsplus_setup/mysql4-upgrade-0.14.1-0.14.2.php 0000666 00000001320 13066146443 0030316 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 13066146443 0027610 0 ustar 00 startSetup(); $installer->endSetup(); app/code/community/Fooman/GoogleAnalyticsPlus/modman 0000666 00000001077 13066146443 0016647 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 13066146443 0024023 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 13066146443 0022223 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/Backend/Accountnumber.php 0000666 00000002140 13066146443 0023346 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 00000003725 13066146443 0020254 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 * * @return string */ public function convert($object, $field) { if (!Mage::getStoreConfig('google/analyticsplus/convertcurrencyenabled')) { return $object->getDataUsingMethod($field); } //getPrice and getFinalPrice do not have equivalents if ($field != 'price' && $field != 'final_price') { $field = 'base_' . $field; } $basecur = Mage::app()->getStore($object->getStoreId())->getBaseCurrency(); if ($basecur) { return sprintf( "%01.4f", Mage::app()->getStore()->roundPrice( $basecur->convert( $object->getDataUsingMethod($field), Mage::getStoreConfig('google/analyticsplus/convertcurrency') ) ) ); } else { //unable to load base currency return zero return '0.0000'; } } /** * 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/tagmanager.phtml 0000666 00000000304 13066146443 0025320 0 ustar 00 shouldInclude()): ?> getTagManagerSnippet(); ?> app/design/frontend/base/default/template/fooman/googleanalyticsplus/ga.phtml 0000666 00000002226 13066146443 0023606 0 ustar 00 shouldIncludeTracking()): ?> getMainAccountId(); $alternativeAccountId = $this->getAlternativeAccountId(); $pageName = $this->getPageName(); $gaUrl = $this->getGaLocation(); $isSuccess = $this->isSuccessPage(); ?> app/design/frontend/base/default/template/fooman/googleanalyticsplus/ga-conversion.phtml 0000666 00000001741 13066146443 0025772 0 ustar 00 isEnabled()):?> app/design/frontend/base/default/template/fooman/googleanalyticsplus/universal.phtml 0000666 00000005160 13066146443 0025227 0 ustar 00 shouldInclude()): ?> isSuccessPage()):?> _getOrder();?> app/design/frontend/base/default/template/fooman/googleanalyticsplus/remarketing.phtml 0000666 00000003255 13066146443 0025532 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 00000003575 13066146443 0021126 0 ustar 00 google_analytics google_analytics google_analytics README.md 0000666 00000003751 13066146443 0006044 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 (we recommend using this as an additional profile while still using Classic Analytics) - 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/googleanalyticsplus.git` **via file transfer (zip download)** please see the releases tab for https://github.com/fooman/googleanalyticsplus/releases
For detailed instructions please refer to the Google Analytics + User Manual here.