yireo_googletagmanager - Version 1.3.17

Version Notes

No notes

Download this release

Release Info

Developer Yireo
Extension yireo_googletagmanager
Version 1.3.17
Comparing to
See all releases


Code changes from version 1.3.13 to 1.3.17

Files changed (23) hide show
  1. app/code/community/Yireo/GoogleTagManager/Block/Category.php +13 -3
  2. app/code/community/Yireo/GoogleTagManager/Block/Custom.php +2 -2
  3. app/code/community/Yireo/GoogleTagManager/Block/Customer.php +2 -2
  4. app/code/community/Yireo/GoogleTagManager/Block/Default.php +2 -2
  5. app/code/community/Yireo/GoogleTagManager/Block/Ecommerce.php +2 -2
  6. app/code/community/Yireo/GoogleTagManager/Block/Order.php +2 -2
  7. app/code/community/Yireo/GoogleTagManager/Block/Product.php +2 -2
  8. app/code/community/Yireo/GoogleTagManager/Block/Quote.php +8 -5
  9. app/code/community/Yireo/GoogleTagManager/Block/Script.php +2 -2
  10. app/code/community/Yireo/GoogleTagManager/Block/Search.php +16 -0
  11. app/code/community/Yireo/GoogleTagManager/Helper/Data.php +51 -2
  12. app/code/community/Yireo/GoogleTagManager/Model/Backend/Source/Method.php +2 -2
  13. app/code/community/Yireo/GoogleTagManager/Model/Container.php +2 -2
  14. app/code/community/Yireo/GoogleTagManager/Model/Observer.php +2 -2
  15. app/code/community/Yireo/GoogleTagManager/etc/config.xml +2 -2
  16. app/code/community/Yireo/GoogleTagManager/etc/system.xml +1 -1
  17. app/design/frontend/base/default/layout/googletagmanager.xml +3 -2
  18. app/design/frontend/base/default/template/googletagmanager/default.phtml +10 -9
  19. app/design/frontend/base/default/template/googletagmanager/ecommerce.phtml +2 -1
  20. app/design/frontend/base/default/template/googletagmanager/script.phtml +2 -4
  21. app/design/frontend/base/default/template/googletagmanager/search.phtml +41 -0
  22. app/etc/modules/Yireo_GoogleTagManager.xml +2 -2
  23. package.xml +1 -1
app/code/community/Yireo/GoogleTagManager/Block/Category.php CHANGED
@@ -3,8 +3,8 @@
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
 
@@ -27,7 +27,17 @@ class Yireo_GoogleTagManager_Block_Category extends Yireo_GoogleTagManager_Block
27
 
28
  // Fetch the current collection from the block and set pagination
29
  $collection = $productListBlock->getLoadedProductCollection();
30
- $collection->setCurPage($this->getCurrentPage())->setPageSize($this->getLimit());
 
 
 
 
 
 
 
 
 
 
31
 
32
  return $collection;
33
  }
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
27
 
28
  // Fetch the current collection from the block and set pagination
29
  $collection = $productListBlock->getLoadedProductCollection();
30
+
31
+ // Set Limit Except for 'all' products
32
+ if ($this->getLimit() != 'all') {
33
+ $collection->setCurPage($this->getCurrentPage())->setPageSize($this->getLimit());
34
+ }
35
+
36
+ // Set default order/direction, failing to do so will prevent proper default order/direction on category views
37
+ // ($this->_isOrdersRendered already set in resource collection but no sorting applied)
38
+ if ($productListBlock->getSortBy()) {
39
+ $collection->setOrder($productListBlock->getSortBy(), $productListBlock->getDefaultDirection());
40
+ }
41
 
42
  return $collection;
43
  }
app/code/community/Yireo/GoogleTagManager/Block/Custom.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Block/Customer.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Block/Default.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Block/Ecommerce.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Block/Order.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Block/Product.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Block/Quote.php CHANGED
@@ -3,8 +3,8 @@
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
 
@@ -29,10 +29,13 @@ class Yireo_GoogleTagManager_Block_Quote extends Yireo_GoogleTagManager_Block_De
29
  $data = array();
30
  foreach($quote->getAllItems() as $item) {
31
  /** @var Mage_Sales_Model_Quote_Item $item */
 
 
 
32
  $data[] = array(
33
- 'sku' => $item->getProduct()->getSku(),
34
- 'name' => $item->getProduct()->getName(),
35
- 'price' => $item->getProduct()->getPrice(),
36
  'quantity' => $item->getQty(),
37
  );
38
  }
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
29
  $data = array();
30
  foreach($quote->getAllItems() as $item) {
31
  /** @var Mage_Sales_Model_Quote_Item $item */
32
+
33
+ $product = $item->getProduct();
34
+
35
  $data[] = array(
36
+ 'sku' => $product->getSku(),
37
+ 'name' => $product->getName(),
38
+ 'price' => Mage::helper('tax')->getPrice($product, $product->getFinalPrice()),
39
  'quantity' => $item->getQty(),
40
  );
41
  }
app/code/community/Yireo/GoogleTagManager/Block/Script.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Block/Search.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GoogleTagManager plugin for Magento
4
+ *
5
+ * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Class Yireo_GoogleTagManager_Block_Search
13
+ */
14
+ class Yireo_GoogleTagManager_Block_Search extends Yireo_GoogleTagManager_Block_Default
15
+ {
16
+ }
app/code/community/Yireo/GoogleTagManager/Helper/Data.php CHANGED
@@ -3,8 +3,8 @@
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
 
@@ -179,6 +179,9 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
179
  // Add category-information
180
  $childScript .= $this->getCategoryScript();
181
 
 
 
 
182
  // Add order-information
183
  $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
184
  if (!empty($lastOrderId)) {
@@ -253,6 +256,31 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
253
  }
254
  }
255
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  /**
257
  * @return string
258
  */
@@ -345,9 +373,16 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
345
  $this->ecommerceData[$name] = $value;
346
  }
347
 
 
 
 
 
 
 
348
  public function onClickProduct($product, $addJsEvent = true)
349
  {
350
  $block = $this->fetchBlock('custom', 'custom', 'product_click.phtml');
 
351
 
352
  if ($block) {
353
  $block->setProduct($product);
@@ -361,9 +396,16 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
361
  return $html;
362
  }
363
 
 
 
 
 
 
 
364
  public function onAddToCart($product, $addJsEvent = true)
365
  {
366
  $block = $this->fetchBlock('custom', 'custom', 'product_addtocart.phtml');
 
367
 
368
  if ($block) {
369
  $block->setProduct($product);
@@ -377,9 +419,16 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
377
  return $html;
378
  }
379
 
 
 
 
 
 
 
380
  public function onRemoveFromCart($product, $addJsEvent = true)
381
  {
382
  $block = $this->fetchBlock('custom', 'custom', 'product_removefromcart.phtml');
 
383
 
384
  if ($block) {
385
  $block->setProduct($product);
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
179
  // Add category-information
180
  $childScript .= $this->getCategoryScript();
181
 
182
+ // Add search-information
183
+ $childScript .= $this->getSearchScript();
184
+
185
  // Add order-information
186
  $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
187
  if (!empty($lastOrderId)) {
256
  }
257
  }
258
 
259
+ /**
260
+ * @return string
261
+ */
262
+ public function getSearchScript()
263
+ {
264
+ $listBlock = Mage::app()->getLayout()->getBlock('search_result_list');
265
+ if (!$listBlock) {
266
+ return '';
267
+ }
268
+
269
+ $productCollection = $listBlock->getLoadedProductCollection();
270
+ if (empty($productCollection) || $productCollection->count() < 1) {
271
+ return '';
272
+ }
273
+
274
+ $searchBlock = $this->fetchBlock('search', 'search', 'search.phtml');
275
+ if (!$searchBlock) {
276
+ return '';
277
+ }
278
+
279
+ $searchBlock->setProducts($productCollection);
280
+ $html = $searchBlock->toHtml();
281
+ return $html;
282
+ }
283
+
284
  /**
285
  * @return string
286
  */
373
  $this->ecommerceData[$name] = $value;
374
  }
375
 
376
+ /**
377
+ * @param $product
378
+ * @param bool $addJsEvent
379
+ *
380
+ * @return string
381
+ */
382
  public function onClickProduct($product, $addJsEvent = true)
383
  {
384
  $block = $this->fetchBlock('custom', 'custom', 'product_click.phtml');
385
+ $html = '';
386
 
387
  if ($block) {
388
  $block->setProduct($product);
396
  return $html;
397
  }
398
 
399
+ /**
400
+ * @param $product
401
+ * @param bool $addJsEvent
402
+ *
403
+ * @return string
404
+ */
405
  public function onAddToCart($product, $addJsEvent = true)
406
  {
407
  $block = $this->fetchBlock('custom', 'custom', 'product_addtocart.phtml');
408
+ $html = '';
409
 
410
  if ($block) {
411
  $block->setProduct($product);
419
  return $html;
420
  }
421
 
422
+ /**
423
+ * @param $product
424
+ * @param bool $addJsEvent
425
+ *
426
+ * @return string
427
+ */
428
  public function onRemoveFromCart($product, $addJsEvent = true)
429
  {
430
  $block = $this->fetchBlock('custom', 'custom', 'product_removefromcart.phtml');
431
+ $html = '';
432
 
433
  if ($block) {
434
  $block->setProduct($product);
app/code/community/Yireo/GoogleTagManager/Model/Backend/Source/Method.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Model/Container.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/Model/Observer.php CHANGED
@@ -3,8 +3,8 @@
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
 
3
  * GoogleTagManager plugin for Magento
4
  *
5
  * @package Yireo_GoogleTagManager
6
+ * @author Yireo (https://www.yireo.com/)
7
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Source License (OSL v3)
9
  */
10
 
app/code/community/Yireo/GoogleTagManager/etc/config.xml CHANGED
@@ -5,14 +5,14 @@
5
  *
6
  * @package Yireo_GoogleTagManager
7
  * @author Yireo
8
- * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
9
  * @license Open Source License (OSL v3)
10
  */
11
  -->
12
  <config>
13
  <modules>
14
  <Yireo_GoogleTagManager>
15
- <version>1.3.13</version>
16
  </Yireo_GoogleTagManager>
17
  </modules>
18
 
5
  *
6
  * @package Yireo_GoogleTagManager
7
  * @author Yireo
8
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
9
  * @license Open Source License (OSL v3)
10
  */
11
  -->
12
  <config>
13
  <modules>
14
  <Yireo_GoogleTagManager>
15
+ <version>1.3.17</version>
16
  </Yireo_GoogleTagManager>
17
  </modules>
18
 
app/code/community/Yireo/GoogleTagManager/etc/system.xml CHANGED
@@ -6,7 +6,7 @@
6
  * @category design_default
7
  * @package Yireo_GoogleTagManager
8
  * @author Yireo
9
- * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
10
  * @license Open Source License (OSL v3)
11
  */
12
  -->
6
  * @category design_default
7
  * @package Yireo_GoogleTagManager
8
  * @author Yireo
9
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
10
  * @license Open Source License (OSL v3)
11
  */
12
  -->
app/design/frontend/base/default/layout/googletagmanager.xml CHANGED
@@ -4,8 +4,8 @@
4
  * GoogleTagManager extension for Magento
5
  *
6
  * @package Yireo_GoogleTagManager
7
- * @author Yireo (http://www.yireo.com/)
8
- * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
9
  * @license Open Source License (OSL)
10
  */
11
  -->
@@ -16,6 +16,7 @@
16
  <block type="googletagmanager/quote" name="googletagmanager_quote" template="googletagmanager/quote.phtml" />
17
  <block type="googletagmanager/product" name="googletagmanager_product" template="googletagmanager/product.phtml" />
18
  <block type="googletagmanager/category" name="googletagmanager_category" template="googletagmanager/category.phtml" />
 
19
  <block type="googletagmanager/ecommerce" name="googletagmanager_ecommerce" template="googletagmanager/ecommerce.phtml" />
20
  <block type="googletagmanager/custom" name="googletagmanager_custom" template="googletagmanager/custom.phtml" />
21
  <block type="googletagmanager/default" name="googletagmanager" template="googletagmanager/default.phtml" />
4
  * GoogleTagManager extension for Magento
5
  *
6
  * @package Yireo_GoogleTagManager
7
+ * @author Yireo (https://www.yireo.com/)
8
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
9
  * @license Open Source License (OSL)
10
  */
11
  -->
16
  <block type="googletagmanager/quote" name="googletagmanager_quote" template="googletagmanager/quote.phtml" />
17
  <block type="googletagmanager/product" name="googletagmanager_product" template="googletagmanager/product.phtml" />
18
  <block type="googletagmanager/category" name="googletagmanager_category" template="googletagmanager/category.phtml" />
19
+ <block type="googletagmanager/search" name="googletagmanager_search" template="googletagmanager/search.phtml" />
20
  <block type="googletagmanager/ecommerce" name="googletagmanager_ecommerce" template="googletagmanager/ecommerce.phtml" />
21
  <block type="googletagmanager/custom" name="googletagmanager_custom" template="googletagmanager/custom.phtml" />
22
  <block type="googletagmanager/default" name="googletagmanager" template="googletagmanager/default.phtml" />
app/design/frontend/base/default/template/googletagmanager/default.phtml CHANGED
@@ -11,22 +11,23 @@
11
  $moduleName = $this->getRequest()->getModuleName();
12
  $controllerName = $this->getRequest()->getControllerName();
13
  $actionName = $this->getRequest()->getActionName();
14
- $route = $moduleName.'/'.$controllerName.'/'.$actionName;
15
  ?>
16
  <?php if ($this->isEnabled()) : ?>
17
  <?php $this->addAttribute('pageType', $route); ?>
18
  <noscript>
19
- <iframe src="//www.googletagmanager.com/ns.html?id=<?= $this->getId(); ?>" height="0" width="0" style="display:none;visibility:hidden"></iframe>
 
20
  </noscript>
21
  <?php $childScript = $this->getChildScript(); ?>
22
  <script>
23
- <?php if (!empty($childScript)) : ?>
24
- <?php if($this->hasAttributes()) : ?>
25
- dataLayer = [<?= $this->getAttributesAsJson(); ?>];
26
- <?php endif; ?>
27
- <?= $childScript; ?>
28
- <?php endif; ?>
29
- (function (w, d, s, l, i) {
30
  w[l] = w[l] || [];
31
  w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'});
32
  var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
11
  $moduleName = $this->getRequest()->getModuleName();
12
  $controllerName = $this->getRequest()->getControllerName();
13
  $actionName = $this->getRequest()->getActionName();
14
+ $route = $moduleName . '/' . $controllerName . '/' . $actionName;
15
  ?>
16
  <?php if ($this->isEnabled()) : ?>
17
  <?php $this->addAttribute('pageType', $route); ?>
18
  <noscript>
19
+ <iframe src="//www.googletagmanager.com/ns.html?id=<?= $this->getId(); ?>" height="0" width="0"
20
+ style="display:none;visibility:hidden"></iframe>
21
  </noscript>
22
  <?php $childScript = $this->getChildScript(); ?>
23
  <script>
24
+ <?php if (!empty($childScript)) : ?>
25
+ <?php if($this->hasAttributes()) : ?>
26
+ dataLayer = [<?= $this->getAttributesAsJson(); ?>];
27
+ <?php endif; ?>
28
+ <?= $childScript; ?>
29
+ <?php endif; ?>
30
+ (function (w, d, s, l, i) {
31
  w[l] = w[l] || [];
32
  w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'});
33
  var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
app/design/frontend/base/default/template/googletagmanager/ecommerce.phtml CHANGED
@@ -9,4 +9,5 @@
9
  */
10
 
11
  $data = $this->getEcommerce();
12
- $this->addAttribute('ecommerce', $data);
 
9
  */
10
 
11
  $data = $this->getEcommerce();
12
+ ?>
13
+ dataLayer.push({'ecommerce': <?php echo json_encode($data); ?>});
app/design/frontend/base/default/template/googletagmanager/script.phtml CHANGED
@@ -7,7 +7,5 @@
7
  * @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Software License
9
  */
10
- ?>
11
- <?php if($this->isEnabled()) : ?>
12
- <?= $this->getScript(); ?>
13
- <?php endif; ?>
7
  * @copyright Copyright (c) 2016 Yireo (https://www.yireo.com/)
8
  * @license Open Software License
9
  */
10
+
11
+ if($this->isEnabled()) echo $this->getScript();
 
 
app/design/frontend/base/default/template/googletagmanager/search.phtml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $loadProducts = (int)Mage::helper('googletagmanager')->getConfigValue('category_products');
11
+ if ($loadProducts > 0) {
12
+ $products = $this->getProducts();
13
+ }
14
+
15
+ if ($this->isEnabled()) {
16
+ if (!empty($products)) {
17
+ $this->addAttribute('categorySize', $products->getSize());
18
+ $categoryProducts = array();
19
+
20
+ $i = 0;
21
+ foreach ($products as $product) {
22
+
23
+ if ($i > $loadProducts) {
24
+ break;
25
+ }
26
+
27
+ $categoryProduct = array();
28
+ $categoryProduct['id'] = $product->getId();
29
+ $categoryProduct['name'] = $product->getName();
30
+ $categoryProduct['sku'] = $product->getSku();
31
+ $categoryProduct['price'] = $product->getPrice();
32
+ $categoryProduct['position'] = $i;
33
+
34
+ $categoryProducts[] = $categoryProduct;
35
+ $i++;
36
+ }
37
+
38
+ $this->addAttribute('categoryProducts', $categoryProducts);
39
+ $this->getModuleHelper()->addEcommerceData('impressions', $categoryProducts);
40
+ }
41
+ }
app/etc/modules/Yireo_GoogleTagManager.xml CHANGED
@@ -4,8 +4,8 @@
4
  * Yireo GoogleTagManager-module for Magento
5
  *
6
  * @package Yireo_GoogleTagManager
7
- * @author Yireo (http://www.yireo.com/)
8
- * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
9
  * @license Open Software License
10
  */
11
  -->
4
  * Yireo GoogleTagManager-module for Magento
5
  *
6
  * @package Yireo_GoogleTagManager
7
+ * @author Yireo (https://www.yireo.com/)
8
+ * @copyright Copyright 2016 Yireo (https://www.yireo.com/)
9
  * @license Open Software License
10
  */
11
  -->
package.xml CHANGED
@@ -1,2 +1,2 @@
1
  <?xml version="1.0"?>
2
- <package><name>yireo_googletagmanager</name><version>1.3.13</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-02-15</date><time>5:52: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="8ed9e3cadaa58ca7e41ad233736a112c"/><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="e0b80aa2adf0c6c6c89d38e9ef7638aa"/><file name="product_addtocart.phtml" hash="ead689aa81c78ac9bb182b96a6edbe90"/><file name="product_click.phtml" hash="1946b2edbcd2295cc21031e72293f268"/><file name="product_removefromcart.phtml" hash="f743569a3c3e5aa3bf209b44fe4fcd51"/><file name="quote.phtml" hash="18c5352672c1b6ef704e60f8c3f035f2"/><file name="script.phtml" hash="9fc6143f2237988f1ff4325d5cfc0969"/></dir></dir><dir name="layout"><file name="googletagmanager.xml" hash="fec2a5570a9953e31657aa50bd334ee1"/></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="229411f43853b6cbf53fa825c466144f"/><file name="system.xml" hash="1a0483ed2cd30bd1ec806797a8624225"/></dir><dir name="Model"><file name="Container.php" hash="70873159e8eb2254b8f701bc7ccf313e"/><file name="Observer.php" hash="fd35c56d813aac90583321588b355a0b"/><dir name="Backend"><dir name="Source"><file name="Method.php" hash="8af7a0459aaa78c93bf8c2d11a1bd46c"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="2f94fc7a2a5197885ab75a1fcf7378c0"/></dir><dir name="Block"><file name="Category.php" hash="001bb9fed52b7307dcd211fd32ab72cb"/><file name="Custom.php" hash="e208f2669b99b54001d90730b1fa5e2f"/><file name="Customer.php" hash="b8c90683ce9860d530c1dfb16e15ecda"/><file name="Default.php" hash="c45054124d9f4a8887685f2811925261"/><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>
1
  <?xml version="1.0"?>
2
+ <package><name>yireo_googletagmanager</name><version>1.3.17</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-05-25</date><time>9:57:21</time><compatible></compatible><dependencies><required><php><min>5.4.0</min><max>7.5.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_GoogleTagManager.xml" hash="c28dd4d6773115b840262bce9a0375c8"/></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="8ed9e3cadaa58ca7e41ad233736a112c"/><file name="customer.phtml" hash="3db76ba18473a1c7f664c1b50db622a4"/><file name="custom.phtml" hash="b888cea900aba4a488968ca88a42813d"/><file name="default.phtml" hash="ad392d0002b73bc5028c4d7704695dda"/><file name="ecommerce.phtml" hash="fcded48968e1b152f828c0b20766a948"/><file name="order.phtml" hash="5dadb37be8798f76651e9bbb55a9bf4a"/><file name="product_addtocart.phtml" hash="ead689aa81c78ac9bb182b96a6edbe90"/><file name="product_click.phtml" hash="1946b2edbcd2295cc21031e72293f268"/><file name="product.phtml" hash="e0b80aa2adf0c6c6c89d38e9ef7638aa"/><file name="product_removefromcart.phtml" hash="f743569a3c3e5aa3bf209b44fe4fcd51"/><file name="quote.phtml" hash="18c5352672c1b6ef704e60f8c3f035f2"/><file name="script.phtml" hash="5ad6b7dcbd3c8073b739e2fe4088dc58"/><file name="search.phtml" hash="ecacabcd592944211d68769dbd7d008d"/></dir></dir><dir name="layout"><file name="googletagmanager.xml" hash="d976e70f22432fe327cdb19a7b34eb21"/></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="f3b0ae527c87b2c4b32a9d822d53edc0"/><file name="system.xml" hash="41c9ad0454073fde42c763bb6aef9175"/></dir><dir name="Model"><file name="Container.php" hash="2a57c7d0e901274854df57d36d6fea99"/><file name="Observer.php" hash="3bed6d647000b1a3c71c1e7706493a3d"/><dir name="Backend"><dir name="Source"><file name="Method.php" hash="457884da29b2f06f7488b35877f9c57d"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="8d28d81a09e0804c98fd468db3c85b8b"/></dir><dir name="Block"><file name="Category.php" hash="6d13b5060f6b72f67451938bc8fbb41d"/><file name="Customer.php" hash="8acd34cb6de2cf52999cb03c61816fd1"/><file name="Custom.php" hash="d8fbfada41ae6b0de6722aac4d4eb51b"/><file name="Default.php" hash="bcf3481a07f5f020224c04fb6e542a3d"/><file name="Ecommerce.php" hash="3095463b7d90cd74dfab059c8fd0bb12"/><file name="Order.php" hash="fcfad1050e3250605002d4a983931bed"/><file name="Product.php" hash="26eed61e01ec7c54b7f49fafa71835dd"/><file name="Quote.php" hash="84d11e9d031461e7be9923a9ef61ff91"/><file name="Script.php" hash="aee5f09b8de72c7e382790130b4e6643"/><file name="Search.php" hash="1b6883a687fa1c25cc8eadfb0fb79dc0"/></dir></dir></dir></dir></dir></dir></target></contents></package>