Version Notes
No notes
Download this release
Release Info
Developer | Yireo |
Extension | yireo_googletagmanager |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.2.0
- app/code/community/Yireo/GoogleTagManager/Block/Category.php +13 -0
- app/code/community/Yireo/GoogleTagManager/Block/Custom.php +13 -0
- app/code/community/Yireo/GoogleTagManager/Block/Default.php +26 -1
- app/code/community/Yireo/GoogleTagManager/Block/Order.php +1 -1
- app/code/community/Yireo/GoogleTagManager/Block/Product.php +13 -0
- app/code/community/Yireo/GoogleTagManager/Block/Quote.php +1 -1
- app/code/community/Yireo/GoogleTagManager/Block/Script.php +17 -0
- app/code/community/Yireo/GoogleTagManager/Helper/Data.php +40 -9
- app/code/community/Yireo/GoogleTagManager/Model/Container.php +13 -0
- app/code/community/Yireo/GoogleTagManager/Model/Observer.php +1 -1
- app/code/community/Yireo/GoogleTagManager/etc/config.xml +2 -2
- app/code/community/Yireo/GoogleTagManager/etc/system.xml +2 -2
- app/design/frontend/base/default/layout/googletagmanager.xml +11 -2
- app/design/frontend/base/default/template/googletagmanager/category.phtml +17 -0
- app/design/frontend/base/default/template/googletagmanager/custom.phtml +12 -0
- app/design/frontend/base/default/template/googletagmanager/default.phtml +9 -0
- app/design/frontend/base/default/template/googletagmanager/order.phtml +6 -10
- app/design/frontend/base/default/template/googletagmanager/product.phtml +18 -0
- app/design/frontend/base/default/template/googletagmanager/quote.phtml +5 -9
- package.xml +1 -1
app/code/community/Yireo/GoogleTagManager/Block/Category.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoogleTagManager plugin for Magento
|
4 |
+
*
|
5 |
+
* @package Yireo_GoogleTagManager
|
6 |
+
* @author Yireo (http://www.yireo.com/)
|
7 |
+
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Yireo_GoogleTagManager_Block_Category extends Yireo_GoogleTagManager_Block_Default
|
12 |
+
{
|
13 |
+
}
|
app/code/community/Yireo/GoogleTagManager/Block/Custom.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoogleTagManager plugin for Magento
|
4 |
+
*
|
5 |
+
* @package Yireo_GoogleTagManager
|
6 |
+
* @author Yireo (http://www.yireo.com/)
|
7 |
+
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Yireo_GoogleTagManager_Block_Custom extends Yireo_GoogleTagManager_Block_Default
|
12 |
+
{
|
13 |
+
}
|
app/code/community/Yireo/GoogleTagManager/Block/Default.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
-
* @license Open Source License
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Block_Default extends Mage_Core_Block_Template
|
@@ -24,4 +24,29 @@ class Yireo_GoogleTagManager_Block_Default extends Mage_Core_Block_Template
|
|
24 |
{
|
25 |
return Mage::helper('googletagmanager')->getConfigValue($key, $default_value);
|
26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Block_Default extends Mage_Core_Block_Template
|
24 |
{
|
25 |
return Mage::helper('googletagmanager')->getConfigValue($key, $default_value);
|
26 |
}
|
27 |
+
|
28 |
+
public function hasAttributes()
|
29 |
+
{
|
30 |
+
$attributes = $this->getAttributes();
|
31 |
+
if(!empty($attributes)) {
|
32 |
+
return true;
|
33 |
+
}
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getAttributesAsJson()
|
38 |
+
{
|
39 |
+
$attributes = $this->getAttributes();
|
40 |
+
return json_encode($attributes);
|
41 |
+
}
|
42 |
+
|
43 |
+
public function setAttribute($name, $value)
|
44 |
+
{
|
45 |
+
Mage::getSingleton('googletagmanager/container')->setData($name, $value);
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getAttributes()
|
49 |
+
{
|
50 |
+
return Mage::getSingleton('googletagmanager/container')->getData();
|
51 |
+
}
|
52 |
}
|
app/code/community/Yireo/GoogleTagManager/Block/Order.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
-
* @license Open Source License
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Block_Order extends Yireo_GoogleTagManager_Block_Default
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Block_Order extends Yireo_GoogleTagManager_Block_Default
|
app/code/community/Yireo/GoogleTagManager/Block/Product.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoogleTagManager plugin for Magento
|
4 |
+
*
|
5 |
+
* @package Yireo_GoogleTagManager
|
6 |
+
* @author Yireo (http://www.yireo.com/)
|
7 |
+
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Yireo_GoogleTagManager_Block_Product extends Yireo_GoogleTagManager_Block_Default
|
12 |
+
{
|
13 |
+
}
|
app/code/community/Yireo/GoogleTagManager/Block/Quote.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
-
* @license Open Source License
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Block_Quote extends Yireo_GoogleTagManager_Block_Default
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Block_Quote extends Yireo_GoogleTagManager_Block_Default
|
app/code/community/Yireo/GoogleTagManager/Block/Script.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoogleTagManager plugin for Magento
|
4 |
+
*
|
5 |
+
* @package Yireo_GoogleTagManager
|
6 |
+
* @author Yireo (http://www.yireo.com/)
|
7 |
+
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Yireo_GoogleTagManager_Block_Script extends Mage_Core_Block_Abstract
|
12 |
+
{
|
13 |
+
public function toHtml()
|
14 |
+
{
|
15 |
+
return Mage::helper('googletagmanager')->getHeaderScript();
|
16 |
+
}
|
17 |
+
}
|
app/code/community/Yireo/GoogleTagManager/Helper/Data.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
-
* @license Open Source License
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
@@ -25,16 +25,36 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
25 |
*/
|
26 |
public function getHeaderScript()
|
27 |
{
|
28 |
-
$
|
29 |
|
30 |
// Check for the frontend layout
|
31 |
if (!($layout = Mage::app()->getFrontController()->getAction()->getLayout())) {
|
32 |
-
return $
|
33 |
}
|
34 |
|
35 |
// Check for the Google Tag Manager block
|
36 |
if (!($block = $layout->getBlock('googletagmanager'))) {
|
37 |
-
return $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
// Add order-information
|
@@ -42,20 +62,31 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
42 |
if(!empty($lastOrderId)) {
|
43 |
$order = Mage::getModel('sales/order')->loadByIncrementId($lastOrderId);
|
44 |
$orderBlock = $layout->getBlock('googletagmanager_order');
|
45 |
-
$orderBlock
|
46 |
-
|
|
|
|
|
47 |
|
48 |
// Add quote-information
|
49 |
} else {
|
50 |
$quote = Mage::getModel('checkout/cart')->getQuote();
|
51 |
if($quote->getId() > 0) {
|
52 |
$quoteBlock = $layout->getBlock('googletagmanager_quote');
|
53 |
-
$quoteBlock
|
54 |
-
|
|
|
|
|
55 |
}
|
56 |
}
|
57 |
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
return $html;
|
60 |
}
|
61 |
}
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
25 |
*/
|
26 |
public function getHeaderScript()
|
27 |
{
|
28 |
+
$childScript = '';
|
29 |
|
30 |
// Check for the frontend layout
|
31 |
if (!($layout = Mage::app()->getFrontController()->getAction()->getLayout())) {
|
32 |
+
return $childScript;
|
33 |
}
|
34 |
|
35 |
// Check for the Google Tag Manager block
|
36 |
if (!($block = $layout->getBlock('googletagmanager'))) {
|
37 |
+
return $childScript;
|
38 |
+
}
|
39 |
+
|
40 |
+
// Add product-information
|
41 |
+
$currentProduct = Mage::registry('current_product');
|
42 |
+
if(!empty($currentProduct)) {
|
43 |
+
$productBlock = $layout->getBlock('googletagmanager_product');
|
44 |
+
if($productBlock) {
|
45 |
+
$productBlock->setProduct($currentProduct);
|
46 |
+
$childScript .= $productBlock->toHtml();
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
// Add category-information
|
51 |
+
$currentCategory = Mage::registry('current_category');
|
52 |
+
if(!empty($currentCategory)) {
|
53 |
+
$categoryBlock = $layout->getBlock('googletagmanager_category');
|
54 |
+
if($categoryBlock) {
|
55 |
+
$categoryBlock->setCategory($currentCategory);
|
56 |
+
$childScript .= $categoryBlock->toHtml();
|
57 |
+
}
|
58 |
}
|
59 |
|
60 |
// Add order-information
|
62 |
if(!empty($lastOrderId)) {
|
63 |
$order = Mage::getModel('sales/order')->loadByIncrementId($lastOrderId);
|
64 |
$orderBlock = $layout->getBlock('googletagmanager_order');
|
65 |
+
if($orderBlock) {
|
66 |
+
$orderBlock->setOrder($order);
|
67 |
+
$childScript .= $orderBlock->toHtml();
|
68 |
+
}
|
69 |
|
70 |
// Add quote-information
|
71 |
} else {
|
72 |
$quote = Mage::getModel('checkout/cart')->getQuote();
|
73 |
if($quote->getId() > 0) {
|
74 |
$quoteBlock = $layout->getBlock('googletagmanager_quote');
|
75 |
+
if($quoteBlock) {
|
76 |
+
$quoteBlock->setQuote($quote);
|
77 |
+
$childScript .= $quoteBlock->toHtml();
|
78 |
+
}
|
79 |
}
|
80 |
}
|
81 |
|
82 |
+
// Add custom information
|
83 |
+
$customBlock = $layout->getBlock('googletagmanager_custom');
|
84 |
+
if($customBlock) {
|
85 |
+
$childScript .= $customBlock->toHtml();
|
86 |
+
}
|
87 |
+
|
88 |
+
$block->setChildScript($childScript);
|
89 |
+
$html = $block->toHtml();
|
90 |
return $html;
|
91 |
}
|
92 |
}
|
app/code/community/Yireo/GoogleTagManager/Model/Container.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoogleTagManager plugin for Magento
|
4 |
+
*
|
5 |
+
* @package Yireo_GoogleTagManager
|
6 |
+
* @author Yireo (http://www.yireo.com/)
|
7 |
+
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Yireo_GoogleTagManager_Model_Container extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
}
|
app/code/community/Yireo/GoogleTagManager/Model/Observer.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
-
* @license Open Source License
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Model_Observer
|
5 |
* @package Yireo_GoogleTagManager
|
6 |
* @author Yireo (http://www.yireo.com/)
|
7 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Source License (OSL v3)
|
9 |
*/
|
10 |
|
11 |
class Yireo_GoogleTagManager_Model_Observer
|
app/code/community/Yireo/GoogleTagManager/etc/config.xml
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
* @package Yireo_GoogleTagManager
|
7 |
* @author Yireo
|
8 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
9 |
-
* @license Open
|
10 |
*/
|
11 |
-->
|
12 |
<config>
|
13 |
<modules>
|
14 |
<Yireo_GoogleTagManager>
|
15 |
-
<version>1.
|
16 |
</Yireo_GoogleTagManager>
|
17 |
</modules>
|
18 |
|
6 |
* @package Yireo_GoogleTagManager
|
7 |
* @author Yireo
|
8 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
9 |
+
* @license Open Source License (OSL v3)
|
10 |
*/
|
11 |
-->
|
12 |
<config>
|
13 |
<modules>
|
14 |
<Yireo_GoogleTagManager>
|
15 |
+
<version>1.2.0</version>
|
16 |
</Yireo_GoogleTagManager>
|
17 |
</modules>
|
18 |
|
app/code/community/Yireo/GoogleTagManager/etc/system.xml
CHANGED
@@ -7,14 +7,14 @@
|
|
7 |
* @package Yireo_GoogleTagManager
|
8 |
* @author Yireo
|
9 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
10 |
-
* @license Open
|
11 |
*/
|
12 |
-->
|
13 |
<config>
|
14 |
<sections>
|
15 |
<googletagmanager translate="label" module="googletagmanager">
|
16 |
<label>Google Tag Manager</label>
|
17 |
-
<tab>
|
18 |
<frontend_type>text</frontend_type>
|
19 |
<sort_order>342</sort_order>
|
20 |
<show_in_default>1</show_in_default>
|
7 |
* @package Yireo_GoogleTagManager
|
8 |
* @author Yireo
|
9 |
* @copyright Copyright (C) 2014 Yireo (http://www.yireo.com/)
|
10 |
+
* @license Open Source License (OSL v3)
|
11 |
*/
|
12 |
-->
|
13 |
<config>
|
14 |
<sections>
|
15 |
<googletagmanager translate="label" module="googletagmanager">
|
16 |
<label>Google Tag Manager</label>
|
17 |
+
<tab>yireo</tab>
|
18 |
<frontend_type>text</frontend_type>
|
19 |
<sort_order>342</sort_order>
|
20 |
<show_in_default>1</show_in_default>
|
app/design/frontend/base/default/layout/googletagmanager.xml
CHANGED
@@ -5,14 +5,23 @@
|
|
5 |
*
|
6 |
* @package Yireo_GoogleTagManager
|
7 |
* @author Yireo (http://www.yireo.com/)
|
8 |
-
* @copyright Copyright (c)
|
9 |
* @license Open Source License (OSL)
|
10 |
*/
|
11 |
-->
|
12 |
<layout>
|
13 |
<default>
|
14 |
-
<block type="googletagmanager/default" name="googletagmanager" template="googletagmanager/default.phtml" />
|
15 |
<block type="googletagmanager/order" name="googletagmanager_order" template="googletagmanager/order.phtml" />
|
16 |
<block type="googletagmanager/quote" name="googletagmanager_quote" template="googletagmanager/quote.phtml" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
</default>
|
18 |
</layout>
|
5 |
*
|
6 |
* @package Yireo_GoogleTagManager
|
7 |
* @author Yireo (http://www.yireo.com/)
|
8 |
+
* @copyright Copyright (c) 2014 Yireo (http://www.yireo.com/)
|
9 |
* @license Open Source License (OSL)
|
10 |
*/
|
11 |
-->
|
12 |
<layout>
|
13 |
<default>
|
|
|
14 |
<block type="googletagmanager/order" name="googletagmanager_order" template="googletagmanager/order.phtml" />
|
15 |
<block type="googletagmanager/quote" name="googletagmanager_quote" template="googletagmanager/quote.phtml" />
|
16 |
+
<block type="googletagmanager/product" name="googletagmanager_product" template="googletagmanager/product.phtml" />
|
17 |
+
<block type="googletagmanager/category" name="googletagmanager_category" template="googletagmanager/category.phtml" />
|
18 |
+
<block type="googletagmanager/custom" name="googletagmanager_custom" template="googletagmanager/custom.phtml" />
|
19 |
+
<block type="googletagmanager/default" name="googletagmanager" template="googletagmanager/default.phtml" />
|
20 |
+
|
21 |
+
<!--
|
22 |
+
<reference name="after_body_start">
|
23 |
+
<block type="googletagmanager/script" name="googletagmanager" />
|
24 |
+
</reference>
|
25 |
+
-->
|
26 |
</default>
|
27 |
</layout>
|
app/design/frontend/base/default/template/googletagmanager/category.phtml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoogleTagManager plugin for Magento
|
4 |
+
*
|
5 |
+
* @package Yireo_GoogleTagManager
|
6 |
+
* @author Yireo (http://www.yireo.com/)
|
7 |
+
* @copyright Copyright (c) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Software License
|
9 |
+
*/
|
10 |
+
?>
|
11 |
+
<?php if($this->isEnabled()) : ?>
|
12 |
+
<?php $category = $this->getCategory(); ?>
|
13 |
+
<?php if(!empty($category) && $category->getId() > 0) : ?>
|
14 |
+
<?php $this->setAttribute('categoryId', $category->getId()); ?>
|
15 |
+
<?php $this->setAttribute('categoryName', $category->getName()); ?>
|
16 |
+
<?php endif; ?>
|
17 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/googletagmanager/custom.phtml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoogleTagManager plugin for Magento
|
4 |
+
*
|
5 |
+
* @package Yireo_GoogleTagManager
|
6 |
+
* @author Yireo (http://www.yireo.com/)
|
7 |
+
* @copyright Copyright (c) 2014 Yireo (http://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/default.phtml
CHANGED
@@ -9,5 +9,14 @@
|
|
9 |
*/
|
10 |
?>
|
11 |
<?php if($this->isEnabled()) : ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=<?php echo $this->getId(); ?>" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','<?php echo $this->getId(); ?>');</script>
|
13 |
<?php endif; ?>
|
9 |
*/
|
10 |
?>
|
11 |
<?php if($this->isEnabled()) : ?>
|
12 |
+
<?php $childScript = $this->getChildScript(); ?>
|
13 |
+
<?php if(!empty($childScript)) : ?>
|
14 |
+
<script>
|
15 |
+
<?php if($this->hasAttributes()) : ?>
|
16 |
+
dataLayer = [<?php echo $this->getAttributesAsJson(); ?>];
|
17 |
+
<?php endif; ?>
|
18 |
+
<?php echo $childScript; ?>
|
19 |
+
</script>
|
20 |
+
<?php endif; ?>
|
21 |
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=<?php echo $this->getId(); ?>" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','<?php echo $this->getId(); ?>');</script>
|
22 |
<?php endif; ?>
|
app/design/frontend/base/default/template/googletagmanager/order.phtml
CHANGED
@@ -9,17 +9,13 @@
|
|
9 |
*/
|
10 |
?>
|
11 |
<?php if($this->isEnabled()) : ?>
|
12 |
-
<script>
|
13 |
<?php $order = $this->getOrder(); ?>
|
14 |
<?php if(!empty($order) && $order->getId() > 0) : ?>
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
'transactionProducts': <?php echo $this->getItemsAsJson(); ?>
|
22 |
-
}];
|
23 |
<?php endif; ?>
|
24 |
-
</script>
|
25 |
<?php endif; ?>
|
9 |
*/
|
10 |
?>
|
11 |
<?php if($this->isEnabled()) : ?>
|
|
|
12 |
<?php $order = $this->getOrder(); ?>
|
13 |
<?php if(!empty($order) && $order->getId() > 0) : ?>
|
14 |
+
<?php $this->setAttribute('transactionId', $order->getIncrementId()); ?>
|
15 |
+
<?php $this->setAttribute('transactionAffiliation', Mage::app()->getWebsite()->getName()); ?>
|
16 |
+
<?php $this->setAttribute('transactionTotal', $order->getGrandTotal()); ?>
|
17 |
+
<?php $this->setAttribute('transactionTax', $order->getGrandTotal() - $order->getSubtotal()); ?>
|
18 |
+
<?php $this->setAttribute('transactionShipping', $order->getShippingAmount()); ?>
|
19 |
+
<?php $this->setAttribute('transactionProducts', $this->getItemsAsJson()); ?>
|
|
|
|
|
20 |
<?php endif; ?>
|
|
|
21 |
<?php endif; ?>
|
app/design/frontend/base/default/template/googletagmanager/product.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoogleTagManager plugin for Magento
|
4 |
+
*
|
5 |
+
* @package Yireo_GoogleTagManager
|
6 |
+
* @author Yireo (http://www.yireo.com/)
|
7 |
+
* @copyright Copyright (c) 2014 Yireo (http://www.yireo.com/)
|
8 |
+
* @license Open Software License
|
9 |
+
*/
|
10 |
+
?>
|
11 |
+
<?php if($this->isEnabled()) : ?>
|
12 |
+
<?php $product = $this->getProduct(); ?>
|
13 |
+
<?php if(!empty($product) && $product->getId() > 0) : ?>
|
14 |
+
<?php $this->setAttribute('productId', $product->getId()); ?>
|
15 |
+
<?php $this->setAttribute('productName', $product->getName()); ?>
|
16 |
+
<?php $this->setAttribute('productSku', $product->getSku()); ?>
|
17 |
+
<?php endif; ?>
|
18 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/googletagmanager/quote.phtml
CHANGED
@@ -9,16 +9,12 @@
|
|
9 |
*/
|
10 |
?>
|
11 |
<?php if($this->isEnabled()) : ?>
|
12 |
-
<script>
|
13 |
<?php $quote = $this->getQuote(); ?>
|
14 |
<?php if(!empty($quote) && $quote->getId() > 0) : ?>
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
'transactionProducts': <?php echo $this->getItemsAsJson(); ?>
|
21 |
-
}];
|
22 |
<?php endif; ?>
|
23 |
-
</script>
|
24 |
<?php endif; ?>
|
9 |
*/
|
10 |
?>
|
11 |
<?php if($this->isEnabled()) : ?>
|
|
|
12 |
<?php $quote = $this->getQuote(); ?>
|
13 |
<?php if(!empty($quote) && $quote->getId() > 0) : ?>
|
14 |
+
<?php $this->setAttribute('transactionId', $quote->getId()); ?>
|
15 |
+
<?php $this->setAttribute('transactionAffiliation', Mage::app()->getWebsite()->getName()); ?>
|
16 |
+
<?php $this->setAttribute('transactionTotal', $quote->getGrandTotal()); ?>
|
17 |
+
<?php $this->setAttribute('transactionTax', $quote->getGrandTotal() - $quote->getSubtotal()); ?>
|
18 |
+
<?php $this->setAttribute('transactionProducts', $this->getItemsAsJson()); ?>
|
|
|
|
|
19 |
<?php endif; ?>
|
|
|
20 |
<?php endif; ?>
|
package.xml
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
<package><name>yireo_googletagmanager</name><version>1.
|
1 |
<?xml version="1.0"?>
|
2 |
+
<package><name>yireo_googletagmanager</name><version>1.2.0</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>2014-12-05</date><time>2:08:49</time><compatible></compatible><dependencies><required><php><min>5.2.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="90f31b076dbc2f5c293c1b61147743ab"/></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="f7ee56063c1c9a55efbef399fd9eef14"/><file name="custom.phtml" hash="2b4ae99a074d314241a1ba7127661c04"/><file name="default.phtml" hash="471f6c6ccf72490adfde5aabe3ed72cc"/><file name="order.phtml" hash="7b2bb2e17cb2bfe969dfcaab617939eb"/><file name="product.phtml" hash="05d781df115908853880ff6b428db662"/><file name="quote.phtml" hash="22f4ddc024af5b9ca4cf6ce0f2078b16"/></dir></dir><dir name="layout"><file name="googletagmanager.xml" hash="39c33332f6dcb06f071404de47e92916"/></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="b5b498e57a14dd6202e2b834dae531a9"/><file name="system.xml" hash="4c5a88fbefbd5520002a89650b3a1b1c"/></dir><dir name="Model"><file name="Container.php" hash="7c32435338aeffedf502f9feeec625d3"/><file name="Observer.php" hash="62e60763d8d1c137065559cfb32bf4f8"/></dir><dir name="Helper"><file name="Data.php" hash="9dad07bf3707312866d173960fc2da9e"/></dir><dir name="Block"><file name="Category.php" hash="921b14604f8647c40847b01f14976ff0"/><file name="Custom.php" hash="20ac881a1e52a65c85bdfa31d15b1e35"/><file name="Default.php" hash="f94c1bc57e2f469b635c2d437b2e4281"/><file name="Order.php" hash="2f3911e31a9bd3bc2117efae13f821f5"/><file name="Product.php" hash="718f68a35ee7ae9126b6d271cf82edb7"/><file name="Quote.php" hash="eb71d7981c9403a468b0eba694e537b1"/><file name="Script.php" hash="70bf97540663c7b5c070159ad0659a2d"/></dir></dir></dir></dir></dir></dir></target></contents></package>
|