Version Notes
No notes
Download this release
Release Info
| Developer | Yireo |
| Extension | yireo_googletagmanager |
| Version | 1.3.8 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3.7 to 1.3.8
- app/code/community/Yireo/GoogleTagManager/Block/Category.php +1 -1
- app/code/community/Yireo/GoogleTagManager/Block/Default.php +22 -0
- app/code/community/Yireo/GoogleTagManager/Block/Ecommerce.php +16 -0
- app/code/community/Yireo/GoogleTagManager/Helper/Data.php +108 -1
- app/code/community/Yireo/GoogleTagManager/etc/config.xml +1 -1
- app/design/frontend/base/default/template/googletagmanager/category.phtml +42 -29
- app/design/frontend/base/default/template/googletagmanager/custom.phtml +3 -3
- app/design/frontend/base/default/template/googletagmanager/customer.phtml +17 -16
- app/design/frontend/base/default/template/googletagmanager/default.phtml +2 -2
- app/design/frontend/base/default/template/googletagmanager/ecommerce.phtml +12 -0
- app/design/frontend/base/default/template/googletagmanager/order.phtml +20 -20
- app/design/frontend/base/default/template/googletagmanager/product.phtml +28 -13
- app/design/frontend/base/default/template/googletagmanager/product_addtocart.phtml +35 -0
- app/design/frontend/base/default/template/googletagmanager/product_click.phtml +33 -0
- app/design/frontend/base/default/template/googletagmanager/product_removefromcart.phtml +35 -0
- app/design/frontend/base/default/template/googletagmanager/quote.phtml +15 -15
- app/design/frontend/base/default/template/googletagmanager/script.phtml +2 -2
- package.xml +1 -1
app/code/community/Yireo/GoogleTagManager/Block/Category.php
CHANGED
|
@@ -16,7 +16,7 @@ class Yireo_GoogleTagManager_Block_Category extends Yireo_GoogleTagManager_Block
|
|
| 16 |
/**
|
| 17 |
* @return Mage_Eav_Model_Entity_Collection_Abstract|null
|
| 18 |
*/
|
| 19 |
-
public function
|
| 20 |
{
|
| 21 |
/** @var Mage_Catalog_Block_Product_List $productListBlock */
|
| 22 |
$productListBlock = Mage::app()->getLayout()->getBlock('product_list');
|
| 16 |
/**
|
| 17 |
* @return Mage_Eav_Model_Entity_Collection_Abstract|null
|
| 18 |
*/
|
| 19 |
+
public function getProductCollection()
|
| 20 |
{
|
| 21 |
/** @var Mage_Catalog_Block_Product_List $productListBlock */
|
| 22 |
$productListBlock = Mage::app()->getLayout()->getBlock('product_list');
|
app/code/community/Yireo/GoogleTagManager/Block/Default.php
CHANGED
|
@@ -123,4 +123,26 @@ class Yireo_GoogleTagManager_Block_Default extends Mage_Core_Block_Template
|
|
| 123 |
{
|
| 124 |
return $this->getContainer()->getData();
|
| 125 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
| 123 |
{
|
| 124 |
return $this->getContainer()->getData();
|
| 125 |
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* Return a product collection
|
| 129 |
+
*
|
| 130 |
+
* @return bool|object
|
| 131 |
+
*/
|
| 132 |
+
public function getProductCollection()
|
| 133 |
+
{
|
| 134 |
+
return false;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* @param $data
|
| 139 |
+
*
|
| 140 |
+
* @return string
|
| 141 |
+
*/
|
| 142 |
+
public function jsonEncode($data)
|
| 143 |
+
{
|
| 144 |
+
$string = json_encode($data);
|
| 145 |
+
$string = str_replace('"', "'", $string);
|
| 146 |
+
return $string;
|
| 147 |
+
}
|
| 148 |
}
|
app/code/community/Yireo/GoogleTagManager/Block/Ecommerce.php
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* GoogleTagManager plugin for Magento
|
| 4 |
+
*
|
| 5 |
+
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (http://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 8 |
+
* @license Open Source License (OSL v3)
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Class Yireo_GoogleTagManager_Block_Ecommerce
|
| 13 |
+
*/
|
| 14 |
+
class Yireo_GoogleTagManager_Block_Ecommerce extends Yireo_GoogleTagManager_Block_Default
|
| 15 |
+
{
|
| 16 |
+
}
|
app/code/community/Yireo/GoogleTagManager/Helper/Data.php
CHANGED
|
@@ -23,6 +23,11 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 23 |
*/
|
| 24 |
const METHOD_LAYOUT = 1;
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
/**
|
| 27 |
* Check whether the module is enabled
|
| 28 |
*
|
|
@@ -125,7 +130,7 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 125 |
* @param $type
|
| 126 |
* @param $template
|
| 127 |
*
|
| 128 |
-
* @return bool
|
| 129 |
*/
|
| 130 |
public function fetchBlock($name, $type, $template)
|
| 131 |
{
|
|
@@ -134,6 +139,7 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 134 |
}
|
| 135 |
|
| 136 |
if ($block = $layout->getBlock('googletagmanager_' . $name)) {
|
|
|
|
| 137 |
$this->debug('Helper: Loading block from layout: '.$name);
|
| 138 |
return $block;
|
| 139 |
}
|
|
@@ -183,6 +189,9 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 183 |
// Add custom information
|
| 184 |
$this->addCustom($childScript);
|
| 185 |
|
|
|
|
|
|
|
|
|
|
| 186 |
$block->setChildScript($childScript);
|
| 187 |
$html = $block->toHtml();
|
| 188 |
|
|
@@ -275,6 +284,23 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 275 |
}
|
| 276 |
}
|
| 277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
/**
|
| 279 |
* @param $childScript string
|
| 280 |
*/
|
|
@@ -286,4 +312,85 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 286 |
$childScript .= $customBlock->toHtml();
|
| 287 |
}
|
| 288 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
}
|
| 23 |
*/
|
| 24 |
const METHOD_LAYOUT = 1;
|
| 25 |
|
| 26 |
+
/**
|
| 27 |
+
* Ecommerce data
|
| 28 |
+
*/
|
| 29 |
+
protected $ecommerceData = array();
|
| 30 |
+
|
| 31 |
/**
|
| 32 |
* Check whether the module is enabled
|
| 33 |
*
|
| 130 |
* @param $type
|
| 131 |
* @param $template
|
| 132 |
*
|
| 133 |
+
* @return bool|Mage_Core_Block_Template
|
| 134 |
*/
|
| 135 |
public function fetchBlock($name, $type, $template)
|
| 136 |
{
|
| 139 |
}
|
| 140 |
|
| 141 |
if ($block = $layout->getBlock('googletagmanager_' . $name)) {
|
| 142 |
+
$block->setTemplate('googletagmanager/' . $template);
|
| 143 |
$this->debug('Helper: Loading block from layout: '.$name);
|
| 144 |
return $block;
|
| 145 |
}
|
| 189 |
// Add custom information
|
| 190 |
$this->addCustom($childScript);
|
| 191 |
|
| 192 |
+
// Add enhanced ecommerce-information
|
| 193 |
+
$this->addEcommerce($childScript);
|
| 194 |
+
|
| 195 |
$block->setChildScript($childScript);
|
| 196 |
$html = $block->toHtml();
|
| 197 |
|
| 284 |
}
|
| 285 |
}
|
| 286 |
|
| 287 |
+
/**
|
| 288 |
+
* @param $childScript string
|
| 289 |
+
*/
|
| 290 |
+
public function addEcommerce(&$childScript)
|
| 291 |
+
{
|
| 292 |
+
$ecommerce = $this->getEcommerceData();
|
| 293 |
+
|
| 294 |
+
if (!empty($ecommerce)) {
|
| 295 |
+
$ecommerceBlock = $this->fetchBlock('ecommerce', 'ecommerce', 'ecommerce.phtml');
|
| 296 |
+
|
| 297 |
+
if ($ecommerceBlock) {
|
| 298 |
+
$ecommerceBlock->setData('ecommerce', $ecommerce);
|
| 299 |
+
$childScript .= $ecommerceBlock->toHtml();
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
/**
|
| 305 |
* @param $childScript string
|
| 306 |
*/
|
| 312 |
$childScript .= $customBlock->toHtml();
|
| 313 |
}
|
| 314 |
}
|
| 315 |
+
|
| 316 |
+
/**
|
| 317 |
+
* @return array
|
| 318 |
+
*/
|
| 319 |
+
protected function getEcommerceData()
|
| 320 |
+
{
|
| 321 |
+
if (empty($this->ecommerceData)) {
|
| 322 |
+
$this->ecommerceData = array(
|
| 323 |
+
'currencyCode' => $this->getCurrencyCode(),
|
| 324 |
+
);
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
return $this->ecommerceData;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
/**
|
| 331 |
+
* @param $name
|
| 332 |
+
* @param $value
|
| 333 |
+
*/
|
| 334 |
+
public function addEcommerceData($name, $value)
|
| 335 |
+
{
|
| 336 |
+
$this->ecommerceData[$name] = $value;
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
public function onClickProduct($product, $addJsEvent = true)
|
| 340 |
+
{
|
| 341 |
+
$block = $this->fetchBlock('custom', 'custom', 'product_click.phtml');
|
| 342 |
+
|
| 343 |
+
if ($block) {
|
| 344 |
+
$block->setProduct($product);
|
| 345 |
+
$html = $block->toHtml();
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
if ($addJsEvent && !empty($html)) {
|
| 349 |
+
$html = 'onclick="'.$html.'"';
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
return $html;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
public function onAddToCart($product, $addJsEvent = true)
|
| 356 |
+
{
|
| 357 |
+
$block = $this->fetchBlock('custom', 'custom', 'product_addtocart.phtml');
|
| 358 |
+
|
| 359 |
+
if ($block) {
|
| 360 |
+
$block->setProduct($product);
|
| 361 |
+
$html = $block->toHtml();
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
if ($addJsEvent && !empty($html)) {
|
| 365 |
+
$html = 'onclick="'.$html.'"';
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
return $html;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
public function onRemoveFromCart($product, $addJsEvent = true)
|
| 372 |
+
{
|
| 373 |
+
$block = $this->fetchBlock('custom', 'custom', 'product_removefromcart.phtml');
|
| 374 |
+
|
| 375 |
+
if ($block) {
|
| 376 |
+
$block->setProduct($product);
|
| 377 |
+
$html = $block->toHtml();
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
if ($addJsEvent && !empty($html)) {
|
| 381 |
+
$html = 'onclick="'.$html.'"';
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
return $html;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
/**
|
| 388 |
+
* Return the current currency code
|
| 389 |
+
*
|
| 390 |
+
* @return string
|
| 391 |
+
*/
|
| 392 |
+
public function getCurrencyCode()
|
| 393 |
+
{
|
| 394 |
+
return Mage::app()->getStore()->getCurrentCurrencyCode();
|
| 395 |
+
}
|
| 396 |
}
|
app/code/community/Yireo/GoogleTagManager/etc/config.xml
CHANGED
|
@@ -12,7 +12,7 @@
|
|
| 12 |
<config>
|
| 13 |
<modules>
|
| 14 |
<Yireo_GoogleTagManager>
|
| 15 |
-
<version>1.3.
|
| 16 |
</Yireo_GoogleTagManager>
|
| 17 |
</modules>
|
| 18 |
|
| 12 |
<config>
|
| 13 |
<modules>
|
| 14 |
<Yireo_GoogleTagManager>
|
| 15 |
+
<version>1.3.8</version>
|
| 16 |
</Yireo_GoogleTagManager>
|
| 17 |
</modules>
|
| 18 |
|
app/design/frontend/base/default/template/googletagmanager/category.phtml
CHANGED
|
@@ -1,38 +1,51 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
-
* @author Yireo (
|
| 7 |
-
* @copyright Copyright (c)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
|
| 11 |
-
$loadProducts = (int)
|
| 12 |
if ($loadProducts > 0) {
|
| 13 |
-
$productCollection = $this->
|
| 14 |
}
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
|
| 11 |
+
$loadProducts = (int)Mage::helper('googletagmanager')->getConfigValue('category_products');
|
| 12 |
if ($loadProducts > 0) {
|
| 13 |
+
$productCollection = $this->getProductCollection();
|
| 14 |
}
|
| 15 |
+
|
| 16 |
+
if ($this->isEnabled()) {
|
| 17 |
+
$category = $this->getCategory();
|
| 18 |
+
if (!empty($category) && $category->getId() > 0) {
|
| 19 |
+
$this->addAttribute('categoryId', $category->getId());
|
| 20 |
+
$this->addAttribute('categoryName', $category->getName());
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
if (!empty($productCollection)) {
|
| 24 |
+
$this->addAttribute('categorySize', $productCollection->getSize());
|
| 25 |
+
$categoryProducts = array();
|
| 26 |
+
|
| 27 |
+
$i = 0;
|
| 28 |
+
foreach ($productCollection as $product) {
|
| 29 |
+
|
| 30 |
+
if ($i > $loadProducts) {
|
| 31 |
+
break;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
$categoryProduct = array();
|
| 35 |
+
$categoryProduct['id'] = $product->getId();
|
| 36 |
+
$categoryProduct['name'] = $product->getName();
|
| 37 |
+
$categoryProduct['sku'] = $product->getSku();
|
| 38 |
+
$categoryProduct['price'] = $product->getPrice();
|
| 39 |
+
if (!empty($category) && $category->getId() > 0) {
|
| 40 |
+
$categoryProduct['category'] = $category->getName();
|
| 41 |
+
}
|
| 42 |
+
$categoryProduct['position'] = $i;
|
| 43 |
+
|
| 44 |
+
$categoryProducts[] = $categoryProduct;
|
| 45 |
+
$i++;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
$this->addAttribute('categoryProducts', $categoryProducts);
|
| 49 |
+
$this->getHelper()->addEcommerceData('impressions', $categoryProducts);
|
| 50 |
+
}
|
| 51 |
+
}
|
app/design/frontend/base/default/template/googletagmanager/custom.phtml
CHANGED
|
@@ -3,10 +3,10 @@
|
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
-
* @author Yireo (
|
| 7 |
-
* @copyright Copyright (c)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
?>
|
| 11 |
<?php if($this->isEnabled()) : ?>
|
| 12 |
-
<?php endif; ?>
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
?>
|
| 11 |
<?php if($this->isEnabled()) : ?>
|
| 12 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/googletagmanager/customer.phtml
CHANGED
|
@@ -3,21 +3,22 @@
|
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
-
* @author Yireo (
|
| 7 |
-
* @copyright Copyright (c)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
+
|
| 11 |
+
if($this->isEnabled()) {
|
| 12 |
+
$customer = $this->getCustomer();
|
| 13 |
+
$customerGroup = $this->getCustomerGroup();
|
| 14 |
+
|
| 15 |
+
if (!empty($customer) && $customer->getId() > 0) {
|
| 16 |
+
$this->addAttribute('customerLoggedIn', 1);
|
| 17 |
+
$this->addAttribute('customerId', $customer->getId());
|
| 18 |
+
} else {
|
| 19 |
+
$this->addAttribute('customerLoggedIn', 0);
|
| 20 |
+
$this->addAttribute('customerId', 0);
|
| 21 |
+
}
|
| 22 |
+
$this->addAttribute('customerGroupId', $customerGroup->getId());
|
| 23 |
+
$this->addAttribute('customerGroupCode', strtoupper($customerGroup->getCustomerGroupCode()));
|
| 24 |
+
}
|
app/design/frontend/base/default/template/googletagmanager/default.phtml
CHANGED
|
@@ -3,8 +3,8 @@
|
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
-
* @author Yireo (
|
| 7 |
-
* @copyright Copyright (c)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
|
app/design/frontend/base/default/template/googletagmanager/ecommerce.phtml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* GoogleTagManager plugin for Magento
|
| 4 |
+
*
|
| 5 |
+
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
+
* @license Open Software License
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
$data = $this->getEcommerce();
|
| 12 |
+
$this->addAttribute('ecommerce', $data);
|
app/design/frontend/base/default/template/googletagmanager/order.phtml
CHANGED
|
@@ -3,25 +3,25 @@
|
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
-
* @author Yireo (
|
| 7 |
-
* @copyright Copyright (c)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
+
|
| 11 |
+
if ($this->isEnabled()) {
|
| 12 |
+
$order = $this->getOrder();
|
| 13 |
+
if (!empty($order) && $order->getId() > 0) {
|
| 14 |
+
$this->addAttribute('transactionEntity', 'ORDER');
|
| 15 |
+
$this->addAttribute('transactionId', $order->getIncrementId());
|
| 16 |
+
$this->addAttribute('transactionDate', $order->getCreatedAt());
|
| 17 |
+
$this->addAttribute('transactionAffiliation', Mage::app()->getWebsite()->getName());
|
| 18 |
+
$this->addAttribute('transactionTotal', (float)$order->getGrandTotal());
|
| 19 |
+
$this->addAttribute('transactionSubtotal', (float)$order->getSubtotal());
|
| 20 |
+
$this->addAttribute('transactionTax', $order->getGrandTotal() - $order->getSubtotal());
|
| 21 |
+
$this->addAttribute('transactionShipping', (float)$order->getShippingAmount());
|
| 22 |
+
$this->addAttribute('transactionPayment', $order->getPayment()->getMethodInstance()->getTitle());
|
| 23 |
+
$this->addAttribute('transactionCurrency', Mage::app()->getStore()->getBaseCurrencyCode());
|
| 24 |
+
$this->addAttribute('transactionPromoCode', $order->getCouponCode());
|
| 25 |
+
$this->addAttribute('transactionProducts', $this->getItems());
|
| 26 |
+
}
|
| 27 |
+
}
|
app/design/frontend/base/default/template/googletagmanager/product.phtml
CHANGED
|
@@ -1,19 +1,34 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
-
* @author Yireo (
|
| 7 |
-
* @copyright Copyright (c)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
+
|
| 11 |
+
if ($this->isEnabled()) {
|
| 12 |
+
|
| 13 |
+
/** @var Mage_Catalog_Model_Product $product */
|
| 14 |
+
$product = $this->getProduct();
|
| 15 |
+
|
| 16 |
+
if (!empty($product) && $product->getId() > 0) {
|
| 17 |
+
$this->addAttribute('productId', $product->getId());
|
| 18 |
+
$this->addAttribute('productName', $product->getName());
|
| 19 |
+
$this->addAttribute('productSku', $product->getSku());
|
| 20 |
+
$this->addAttribute('productPrice', $product->getPrice());
|
| 21 |
+
|
| 22 |
+
$categoryName = $product->getCategory()->getName();
|
| 23 |
+
$this->getHelper()->addEcommerceData('actionField', array('list' => $categoryName));
|
| 24 |
+
|
| 25 |
+
$productData = array(
|
| 26 |
+
'name' => $product->getName(),
|
| 27 |
+
'id' => $product->getId(),
|
| 28 |
+
'price' => $product->getPrice(),
|
| 29 |
+
'brand' => $product->getManufacturer(),
|
| 30 |
+
'category' => $categoryName,
|
| 31 |
+
);
|
| 32 |
+
$this->getHelper()->addEcommerceData('detail', array($productData));
|
| 33 |
+
}
|
| 34 |
+
}
|
app/design/frontend/base/default/template/googletagmanager/product_addtocart.phtml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* GoogleTagManager plugin for Magento
|
| 4 |
+
*
|
| 5 |
+
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
+
* @license Open Software License
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* To use this code, add the following line to your PHTML templates:
|
| 13 |
+
* <?php $gtm = Mage::helper('googletagmanager'); ?>
|
| 14 |
+
* <?php echo $gtm->onAddToCart($_product); ?>
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/** @var Mage_Catalog_Model_Product $product */
|
| 18 |
+
$product = $this->getProduct();
|
| 19 |
+
$data = array(
|
| 20 |
+
'event' => 'addToCart',
|
| 21 |
+
'ecommerce' => array(
|
| 22 |
+
'currencyCode' => $this->getHelper()->getCurrencyCode(),
|
| 23 |
+
'click' => array(
|
| 24 |
+
'products' => array(
|
| 25 |
+
array(
|
| 26 |
+
'name' => $product->getName(),
|
| 27 |
+
'id' => $product->getId(),
|
| 28 |
+
'quantity' => 1,
|
| 29 |
+
)
|
| 30 |
+
)
|
| 31 |
+
)
|
| 32 |
+
),
|
| 33 |
+
);
|
| 34 |
+
?>
|
| 35 |
+
dataLayer.push(<?php echo $this->jsonEncode($data); ?>);
|
app/design/frontend/base/default/template/googletagmanager/product_click.phtml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* GoogleTagManager plugin for Magento
|
| 4 |
+
*
|
| 5 |
+
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
+
* @license Open Software License
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* To use this code, add the following line to your PHTML templates:
|
| 13 |
+
* <?php $gtm = Mage::helper('googletagmanager'); ?>
|
| 14 |
+
* <?php echo $gtm->onClickProduct($_product); ?>
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/** @var Mage_Catalog_Model_Product $product */
|
| 18 |
+
$product = $this->getProduct();
|
| 19 |
+
$data = array(
|
| 20 |
+
'event' => 'productClick',
|
| 21 |
+
'ecommerce' => array(
|
| 22 |
+
'click' => array(
|
| 23 |
+
'products' => array(
|
| 24 |
+
array(
|
| 25 |
+
'name' => $product->getName(),
|
| 26 |
+
'id' => $product->getId(),
|
| 27 |
+
)
|
| 28 |
+
)
|
| 29 |
+
)
|
| 30 |
+
),
|
| 31 |
+
);
|
| 32 |
+
?>
|
| 33 |
+
dataLayer.push(<?php echo $this->jsonEncode($data); ?>);
|
app/design/frontend/base/default/template/googletagmanager/product_removefromcart.phtml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* GoogleTagManager plugin for Magento
|
| 4 |
+
*
|
| 5 |
+
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
+
* @license Open Software License
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* To use this code, add the following line to your PHTML templates:
|
| 13 |
+
* <?php $gtm = Mage::helper('googletagmanager'); ?>
|
| 14 |
+
* <?php echo $gtm->onRemoveFromCart($_product); ?>
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/** @var Mage_Catalog_Model_Product $product */
|
| 18 |
+
$product = $this->getProduct();
|
| 19 |
+
$data = array(
|
| 20 |
+
'event' => 'removeFromCart',
|
| 21 |
+
'ecommerce' => array(
|
| 22 |
+
'currencyCode' => $this->getHelper()->getCurrencyCode(),
|
| 23 |
+
'click' => array(
|
| 24 |
+
'products' => array(
|
| 25 |
+
array(
|
| 26 |
+
'name' => $product->getName(),
|
| 27 |
+
'id' => $product->getId(),
|
| 28 |
+
'quantity' => 1,
|
| 29 |
+
)
|
| 30 |
+
)
|
| 31 |
+
)
|
| 32 |
+
),
|
| 33 |
+
);
|
| 34 |
+
?>
|
| 35 |
+
dataLayer.push(<?php echo $this->jsonEncode($data); ?>);
|
app/design/frontend/base/default/template/googletagmanager/quote.phtml
CHANGED
|
@@ -3,20 +3,20 @@
|
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
-
* @author Yireo (
|
| 7 |
-
* @copyright Copyright (c)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
+
|
| 11 |
+
if($this->isEnabled()) {
|
| 12 |
+
$quote = $this->getQuote();
|
| 13 |
+
if(!empty($quote) && $quote->getId() > 0) {
|
| 14 |
+
$this->addAttribute('transactionEntity', 'QUOTE');
|
| 15 |
+
$this->addAttribute('transactionId', $quote->getId());
|
| 16 |
+
$this->addAttribute('transactionId', $quote->getId());
|
| 17 |
+
$this->addAttribute('transactionAffiliation', Mage::app()->getWebsite()->getName());
|
| 18 |
+
$this->addAttribute('transactionTotal', (float)$quote->getGrandTotal());
|
| 19 |
+
$this->addAttribute('transactionTax', $quote->getGrandTotal() - $quote->getSubtotal());
|
| 20 |
+
$this->addAttribute('transactionProducts', $this->getItemsAsJson());
|
| 21 |
+
}
|
| 22 |
+
}
|
app/design/frontend/base/default/template/googletagmanager/script.phtml
CHANGED
|
@@ -3,8 +3,8 @@
|
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
-
* @author Yireo (
|
| 7 |
-
* @copyright Copyright (c)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
?>
|
| 3 |
* GoogleTagManager plugin for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_GoogleTagManager
|
| 6 |
+
* @author Yireo (https://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
?>
|
package.xml
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
-
<package><name>yireo_googletagmanager</name><version>1.3.
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
+
<package><name>yireo_googletagmanager</name><version>1.3.8</version><stability>stable</stability><license>Open Source License</license><channel>community</channel><extends></extends><summary>No summary</summary><description>No description</description><notes>No notes</notes><authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors><date>2016-01-28</date><time>2:14:36</time><compatible></compatible><dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_GoogleTagManager.xml" hash="420bde8207c2ed151e50ef4b7df1c28f"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="googletagmanager"><file name="category.phtml" hash="ac826696d14d1985864563900264537b"/><file name="custom.phtml" hash="b888cea900aba4a488968ca88a42813d"/><file name="customer.phtml" hash="3db76ba18473a1c7f664c1b50db622a4"/><file name="default.phtml" hash="b2247df055e48fc6ae8cb535e8ec9f52"/><file name="ecommerce.phtml" hash="da3bbe9f182ff24a62ad84d7d8c8b7bc"/><file name="order.phtml" hash="5dadb37be8798f76651e9bbb55a9bf4a"/><file name="product.phtml" hash="c9c3856a68f686dd225738d7c3947d29"/><file name="product_addtocart.phtml" hash="61928e816993230f6de9925d83fe6219"/><file name="product_click.phtml" hash="1946b2edbcd2295cc21031e72293f268"/><file name="product_removefromcart.phtml" hash="694db96f70ab2fddc2d1e116582567e7"/><file name="quote.phtml" hash="18c5352672c1b6ef704e60f8c3f035f2"/><file name="script.phtml" hash="9fc6143f2237988f1ff4325d5cfc0969"/></dir></dir><dir name="layout"><file name="googletagmanager.xml" hash="4b2e83f2e964891da358c9a64647a043"/></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Yireo"><dir name="GoogleTagManager"><dir name="etc"><file name="config.xml" hash="f2d35d9183ada60f72a1719d4e5064c4"/><file name="system.xml" hash="1a0483ed2cd30bd1ec806797a8624225"/></dir><dir name="Model"><file name="Container.php" hash="70873159e8eb2254b8f701bc7ccf313e"/><file name="Observer.php" hash="e9055a00cd61dfaea748e42d0ed7457f"/><dir name="Backend"><dir name="Source"><file name="Method.php" hash="8af7a0459aaa78c93bf8c2d11a1bd46c"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="bfaf7740830c6f557fae81e108bd70f4"/></dir><dir name="Block"><file name="Category.php" hash="63aac465df78b4f57b93831ff02c6d55"/><file name="Custom.php" hash="e208f2669b99b54001d90730b1fa5e2f"/><file name="Customer.php" hash="b8c90683ce9860d530c1dfb16e15ecda"/><file name="Default.php" hash="0e169aa24248e08f4a6ffbb3d286df41"/><file name="Ecommerce.php" hash="13bb03fab65e9afe756bc087ba328302"/><file name="Order.php" hash="eaaa92e54a6f98c8c39ee484dff1a7bb"/><file name="Product.php" hash="7427e6ff8ef6efa9acaac933a3e76b4a"/><file name="Quote.php" hash="d4ada2d05f420e396849780ad547c1dd"/><file name="Script.php" hash="efe492a317563bfe87772f678a338088"/></dir></dir></dir></dir></dir></dir></target></contents></package>
|
