Chapagain_GoogleTagManager - Version 0.1.0

Version Notes

Initial Release

Download this release

Release Info

Developer Mukesh Chapagain
Extension Chapagain_GoogleTagManager
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Chapagain/GoogleTagManager/Block/Gtm.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chapagain_GoogleTagManager_Block_Gtm extends Mage_Core_Block_Template
4
+ {
5
+ public function getIsHomePage()
6
+ {
7
+ $routeName = Mage::app()->getRequest()->getRouteName();
8
+ $identifier = Mage::getSingleton('cms/page')->getIdentifier();
9
+
10
+ if($routeName == 'cms' && $identifier == 'home') {
11
+ return true;
12
+ } else {
13
+ return false;
14
+ }
15
+ }
16
+
17
+ public function getIsOrderSuccessPage()
18
+ {
19
+ if (strpos(Mage::app()->getRequest()->getPathInfo(), '/checkout/onepage/success') !== false) {
20
+ return true;
21
+ }
22
+ return false;
23
+ }
24
+
25
+ public function getIsCartPage()
26
+ {
27
+ if (strpos(Mage::app()->getRequest()->getPathInfo(), '/checkout/cart') !== false) {
28
+ return true;
29
+ }
30
+ return false;
31
+ }
32
+
33
+ public function getIsCheckoutPage()
34
+ {
35
+ if (strpos(Mage::app()->getRequest()->getPathInfo(), '/checkout/onepage') !== false) {
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+
41
+ public function getCurrentProduct()
42
+ {
43
+ return Mage::registry('current_product');
44
+ }
45
+
46
+ public function getCurrentCategory()
47
+ {
48
+ return Mage::registry('current_category');
49
+ }
50
+
51
+ public function getOrder()
52
+ {
53
+ if ($this->getIsOrderSuccessPage()) {
54
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
55
+ $order = Mage::getModel('sales/order')->load($orderId);
56
+ if (!$order) {
57
+ return false;
58
+ }
59
+ return $order;
60
+ }
61
+ return false;
62
+ }
63
+
64
+ public function getDataLayerProduct()
65
+ {
66
+ if ($product = $this->getCurrentProduct()) {
67
+
68
+ $categoryCollection = $product->getCategoryCollection();
69
+
70
+ $categories = array();
71
+ foreach ($categoryCollection as $category) {
72
+ $categories[] = Mage::getModel('catalog/category')->load($category->getEntityId())->getName();
73
+ }
74
+
75
+ $objProduct = new stdClass();
76
+ $objProduct->name = $product->getName();
77
+ $objProduct->id = $product->getSku();
78
+ $objProduct->price = Mage::getModel('directory/currency')->formatTxt($product->getPrice(), array('display' => Zend_Currency::NO_SYMBOL));
79
+ $objProduct->category = implode('|', $categories);
80
+
81
+ $objEcommerce = new stdClass();
82
+ $objEcommerce->ecommerce = new stdClass();
83
+ $objEcommerce->ecommerce->detail = new stdClass();
84
+ $objEcommerce->ecommerce->detail->actionField = new stdClass();
85
+ $objEcommerce->ecommerce->detail->actionField->list = 'Catalog';
86
+ $objEcommerce->ecommerce->detail->products = $objProduct;
87
+
88
+ /*$objAddToCart = new stdClass();
89
+ $objAddToCart->event = 'addToCart';
90
+ $objAddToCart->ecommerce = new stdClass();
91
+ $objAddToCart->ecommerce->add = new stdClass();
92
+ $objAddToCart->ecommerce->add->products = $objProduct;*/
93
+
94
+ $pageCategory = json_encode(array('pageCategory' => 'product-detail'), JSON_PRETTY_PRINT);
95
+
96
+ $dataScript = PHP_EOL;
97
+
98
+ $dataScript .= '<script type="text/javascript">'.PHP_EOL.'dataLayer = [' . $pageCategory . '];'.PHP_EOL.'</script>';
99
+
100
+ $dataScript .= PHP_EOL.PHP_EOL;
101
+
102
+ $dataScript .= '<script type="text/javascript">'.PHP_EOL.'dataLayer.push('. json_encode($objEcommerce, JSON_PRETTY_PRINT) . ');'.PHP_EOL.'</script>';
103
+
104
+ //$dataScript .= PHP_EOL.PHP_EOL;
105
+
106
+ //$dataScript .= '<script type="text/javascript">'.PHP_EOL.'dataLayer.push('. json_encode($objAddToCart, JSON_PRETTY_PRINT) . ');'.PHP_EOL.'</script>';
107
+
108
+ return $dataScript;
109
+ }
110
+ }
111
+
112
+ public function getDataLayerOrder()
113
+ {
114
+ if ($order = $this->getOrder()) {
115
+
116
+ $aItems = array();
117
+ $productItems = array();
118
+ foreach ($order->getAllVisibleItems() as $item) {
119
+
120
+ $categoryCollection = $item->getProduct()->getCategoryCollection();
121
+ $categories = array();
122
+ foreach ($categoryCollection as $category) {
123
+ $categories[] = Mage::getModel('catalog/category')->load($category->getEntityId())->getName();
124
+ }
125
+
126
+ $productItem = array();
127
+ $productItem['name'] = $item->getName();
128
+ $productItem['id'] = $item->getSku();
129
+ $productItem['price'] = Mage::getModel('directory/currency')->formatTxt($item->getBasePrice(), array('display' => Zend_Currency::NO_SYMBOL));
130
+ $productItem['category'] = implode('|', $categories);
131
+ $productItem['quantity'] = intval($item->getQtyOrdered()); // converting qty from decimal to integer
132
+ $productItem['coupon'] = '';
133
+ $productItems[] = (object) $productItem;
134
+
135
+ $objItem = array();
136
+ $objItem['sku'] = $item->getSku();
137
+ $objItem['name'] = $item->getName();
138
+ $objItem['category'] = implode('|', $categories);
139
+ $objItem['price'] = Mage::getModel('directory/currency')->formatTxt($item->getBasePrice(), array('display' => Zend_Currency::NO_SYMBOL));
140
+ $objItem['quantity'] = intval($item->getQtyOrdered()); // converting qty from decimal to integer
141
+ $aItems[] = (object) $objItem;
142
+ }
143
+
144
+ $objOrder = new stdClass();
145
+
146
+ $objOrder->transactionId = $order->getIncrementId();
147
+ $objOrder->transactionAffiliation = Mage::app()->getStore()->getFrontendName();
148
+ $objOrder->transactionTotal = Mage::getModel('directory/currency')->formatTxt($order->getBaseGrandTotal(), array('display' => Zend_Currency::NO_SYMBOL));
149
+ $objOrder->transactionTax = Mage::getModel('directory/currency')->formatTxt($order->getBaseTaxAmount(), array('display' => Zend_Currency::NO_SYMBOL));
150
+ $objOrder->transactionShipping = Mage::getModel('directory/currency')->formatTxt($order->getBaseShippingAmount(), array('display' => Zend_Currency::NO_SYMBOL));
151
+
152
+ $objOrder->transactionProducts = $aItems;
153
+
154
+ $objOrder->ecommerce = new stdClass();
155
+ $objOrder->ecommerce->purchase = new stdClass();
156
+ $objOrder->ecommerce->purchase->actionField = new stdClass();
157
+ $objOrder->ecommerce->purchase->actionField->id = $order->getIncrementId();
158
+ $objOrder->ecommerce->purchase->actionField->affiliation = Mage::app()->getStore()->getFrontendName();
159
+ $objOrder->ecommerce->purchase->actionField->revenue = Mage::getModel('directory/currency')->formatTxt($order->getBaseGrandTotal(), array('display' => Zend_Currency::NO_SYMBOL));
160
+ $objOrder->ecommerce->purchase->actionField->tax = Mage::getModel('directory/currency')->formatTxt($order->getBaseTaxAmount(), array('display' => Zend_Currency::NO_SYMBOL));
161
+ $objOrder->ecommerce->purchase->actionField->shipping = Mage::getModel('directory/currency')->formatTxt($order->getBaseShippingAmount(), array('display' => Zend_Currency::NO_SYMBOL));
162
+ $coupon = $order->getCouponCode();
163
+ $objOrder->ecommerce->purchase->actionField->coupon = $coupon == null ? '' : $coupon;
164
+
165
+ $objOrder->ecommerce->products = $productItems;
166
+
167
+ $pageCategory = json_encode(array('pageCategory' => 'order-success'), JSON_PRETTY_PRINT);
168
+
169
+ $dataScript = PHP_EOL;
170
+
171
+ $dataScript .= '<script type="text/javascript">'.PHP_EOL.'dataLayer = [' . $pageCategory . '];'.PHP_EOL.'</script>';
172
+
173
+ $dataScript .= PHP_EOL.PHP_EOL;
174
+
175
+ $dataScript .= '<script type="text/javascript">'.PHP_EOL.'dataLayer.push('. json_encode($objOrder, JSON_PRETTY_PRINT) . ');'.PHP_EOL.'</script>';
176
+
177
+ return $dataScript;
178
+ }
179
+ }
180
+ }
181
+
182
+ ?>
app/code/community/Chapagain/GoogleTagManager/Block/System/Config/Info.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Chapagain
4
+ * @package Chapagain_GoogleTagManager
5
+ * @author mukesh.chapagain@gmail.com
6
+ * @website http://blog.chapagain.com.np
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Chapagain_GoogleTagManager_Block_System_Config_Info
10
+ extends Mage_Adminhtml_Block_Abstract
11
+ implements Varien_Data_Form_Element_Renderer_Interface
12
+ {
13
+
14
+ /**
15
+ * Render fieldset html
16
+ *
17
+ * @param Varien_Data_Form_Element_Abstract $element
18
+ * @return string
19
+ */
20
+ public function render(Varien_Data_Form_Element_Abstract $element)
21
+ {
22
+ $html = '<div style="background:url(\'http://www.gravatar.com/avatar/c01354fc5d46f88822d737d2a1ce981c.jpg?s=150\') no-repeat scroll 15px center #EAF0EE;border:1px solid #CCCCCC;margin-bottom:10px;padding:20px 20px 20px 180px;">
23
+ <h4>About the Developer</h4>
24
+ <p>
25
+ <strong>Mukesh Chapagain</strong> <br />
26
+ Web developer, Programmer, Blogger, Engineer <br />
27
+ Freelancer with specialization in Magento eCommerce<br />
28
+ <br />
29
+ <a href="http://blog.chapagain.com.np" target="_blank">Blog</a> |
30
+ <a href="mailto:mukesh.chapagain@gmail.com">Email</a> |
31
+ <a href="http://linkedin.com/in/chapagain" target="_blank">LinkedIn</a> |
32
+ <a href="http://github.com/chapagain" target="_blank">GitHub</a> |
33
+ <a href="http://twitter.com/chapagain" target="_blank">Twitter</a> |
34
+ <a href="http://facebook.com/mukesh.chapagain" target="_blank">Facebook</a>
35
+ <br />
36
+ More extensions by the developer at <a href="http://www.magentocommerce.com/magento-connect/developer/chapagain" target="_blank">MagentoConnect</a>
37
+ </p>
38
+ </div>';
39
+
40
+ return $html;
41
+ }
42
+ }
app/code/community/Chapagain/GoogleTagManager/Helper/Data.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chapagain_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ const CONFIG_GTM_GENERAL_IS_ENABLE = 'googletagmanager/general/is_enable';
6
+ const CONFIG_GTM_GENERAL_CONTAINER_ID = 'googletagmanager/general/container_id';
7
+ const CONFIG_GTM_GENERAL_IS_ENABLE_DATA_LAYER = 'googletagmanager/general/is_enable_data_layer';
8
+
9
+ public function getContainerId()
10
+ {
11
+ return Mage::getStoreConfig(self::CONFIG_GTM_GENERAL_CONTAINER_ID);
12
+ }
13
+
14
+ public function getIsEnable()
15
+ {
16
+ return Mage::getStoreConfig(self::CONFIG_GTM_GENERAL_IS_ENABLE);
17
+ }
18
+
19
+ public function getIsEnableDataLayer()
20
+ {
21
+ return Mage::getStoreConfig(self::CONFIG_GTM_GENERAL_IS_ENABLE_DATA_LAYER);
22
+ }
23
+
24
+ /**
25
+ * Checks if current page is product view page
26
+ *
27
+ * @return Mage_Catalog_Model_Product|false
28
+ */
29
+ public function checkCurrentProduct()
30
+ {
31
+ $product = Mage::registry('current_product');
32
+ if (!$product) {
33
+ return false;
34
+ }
35
+ return $product;
36
+ }
37
+
38
+ /**
39
+ * Checks if customer is login
40
+ * Returns customer ID if customer is logged in
41
+ * Else returns false
42
+ *
43
+ * @return integer|false
44
+ */
45
+ public function checkCustomerLogin()
46
+ {
47
+ $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
48
+ if (!$customerId) {
49
+ return false;
50
+ }
51
+ return $customerId;
52
+ }
53
+
54
+ }
55
+
56
+ ?>
app/code/community/Chapagain/GoogleTagManager/Model/Gtm.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chapagain_GoogleTagManager_Model_Gtm extends Mage_Core_Model_Abstract
4
+ {
5
+ /**
6
+ * Get product by sku
7
+ *
8
+ * @param Mage_Catalog_Model_Product
9
+ */
10
+ public function getProductBySku($sku)
11
+ {
12
+ $collection = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
13
+ return $collection;
14
+ }
15
+
16
+ }
17
+
18
+ ?>
app/code/community/Chapagain/GoogleTagManager/controllers/IndexController.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chapagain_GoogleTagManager_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * Get customer session data
7
+ */
8
+ public function getCustomerSession()
9
+ {
10
+ return Mage::getSingleton('customer/session');
11
+ }
12
+
13
+ /**
14
+ * Get core session data
15
+ */
16
+ public function getCoreSession()
17
+ {
18
+ return Mage::getSingleton('core/session');
19
+ }
20
+
21
+
22
+ }
23
+
24
+ ?>
app/code/community/Chapagain/GoogleTagManager/etc/adminhtml.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <googletagmanager>
15
+ <title>GoogleTagManager</title>
16
+ </googletagmanager>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ </config>
app/code/community/Chapagain/GoogleTagManager/etc/config.xml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Chapagain_GoogleTagManager>
5
+ <version>0.1.0</version>
6
+ </Chapagain_GoogleTagManager>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <googletagmanager>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Chapagain_GoogleTagManager</module>
14
+ <frontName>googletagmanager</frontName>
15
+ </args>
16
+ </googletagmanager>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <googletagmanager>
21
+ <file>chapagain/googletagmanager.xml</file>
22
+ </googletagmanager>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <googletagmanageradmin>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Chapagain_GoogleTagManager</module>
32
+ <frontName>googletagmanageradmin</frontName>
33
+ </args>
34
+ </googletagmanageradmin>
35
+ </routers>
36
+ </admin>
37
+ <global>
38
+ <models>
39
+ <googletagmanager>
40
+ <class>Chapagain_GoogleTagManager_Model</class>
41
+ </googletagmanager>
42
+ </models>
43
+ <blocks>
44
+ <googletagmanager>
45
+ <class>Chapagain_GoogleTagManager_Block</class>
46
+ </googletagmanager>
47
+ </blocks>
48
+ <helpers>
49
+ <googletagmanager>
50
+ <class>Chapagain_GoogleTagManager_Helper</class>
51
+ </googletagmanager>
52
+ </helpers>
53
+ </global>
54
+ </config>
app/code/community/Chapagain/GoogleTagManager/etc/system.xml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <chapagainall translate="label" module="googletagmanager">
5
+ <label>Chapagain Extensions</label>
6
+ <sort_order>250</sort_order>
7
+ </chapagainall>
8
+ </tabs>
9
+ <sections>
10
+ <chapagaininfo translate="label" module="googletagmanager">
11
+ <label>Info</label>
12
+ <tab>chapagainall</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <info>
20
+ <frontend_model>googletagmanager/system_config_info</frontend_model>
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ </info>
26
+ </groups>
27
+ </chapagaininfo>
28
+
29
+ <googletagmanager module="googletagmanager">
30
+ <label>Google Tag Manager</label>
31
+ <tab>chapagainall</tab>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>100</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <groups>
38
+ <general translate="label">
39
+ <label>General Settings</label>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>20</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <fields>
46
+ <is_enable translate="label comment">
47
+ <label>Enable</label>
48
+ <comment>Enable/Disable Google Tag Manager</comment>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_yesno</source_model>
51
+ <sort_order>10</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </is_enable>
56
+ <container_id translate="label comment">
57
+ <label>Container ID</label>
58
+ <comment>GTM Container ID</comment>
59
+ <frontend_type>text</frontend_type>
60
+ <sort_order>20</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </container_id>
65
+ <is_enable_data_layer translate="label comment">
66
+ <label>Enable Data Layer</label>
67
+ <!--<comment>Enable/Disable Google Tag Manager</comment>-->
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>30</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ </is_enable_data_layer>
75
+ </fields>
76
+ </general>
77
+ </groups>
78
+ </googletagmanager>
79
+ </sections>
80
+ </config>
app/design/frontend/base/default/layout/chapagain/googletagmanager.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+
5
+ <!--
6
+ Default layout, loads most of the pages
7
+ -->
8
+
9
+ <default>
10
+ <!-- Chapagain_GoogleTagManager -->
11
+ <reference name="after_body_start" before="-">
12
+ <block type="googletagmanager/gtm" name="chapagain_google_tag_manager" as="chapagain_google_tag manager" template="chapagain/googletagmanager/gtm.phtml" />
13
+ </reference>
14
+ </default>
15
+ </layout>
app/design/frontend/base/default/template/chapagain/googletagmanager/gtm.phtml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_helper = $this->helper('googletagmanager');
3
+ $_containerId = trim($_helper->getContainerId());
4
+ if ($_helper->getIsEnable()):
5
+ ?>
6
+ <!-- Google Tag Manager -->
7
+
8
+ <?php
9
+ if ($_helper->getIsEnableDataLayer()):
10
+ echo $this->getDataLayerProduct(); // Product Detail Page
11
+ echo $this->getDataLayerOrder(); // Order Success Page
12
+ endif;
13
+ ?>
14
+
15
+ <noscript><iframe src="//www.googletagmanager.com/ns.html?id=<?php echo $_containerId ?>"
16
+ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
17
+ <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
18
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
19
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
20
+ '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
21
+ })(window,document,'script','dataLayer','<?php echo $_containerId ?>');</script>
22
+
23
+ <!-- End Google Tag Manager -->
24
+
25
+ <?php endif; ?>
app/etc/modules/Chapagain_GoogleTagManager.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Chapagain_GoogleTagManager>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Chapagain_GoogleTagManager>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package><name>Chapagain_GoogleTagManager</name><version>0.1.0</version><stability>stable</stability><license>OSL v3.0</license><channel>community</channel><extends></extends><summary>This extension allows you to integrate Google Tag Manager to your site.</summary><description>This extension allows you to integrate Google Tag Manager to your site. This extension also provides ecommerce transaction tracking feature. You just need to enter your Tag Manager container id in the extension's configuration settings.
3
+
4
+ You can manage the extension settings from System -&gt; Configuration -&gt; CHAPAGAIN EXTENSIONS -&gt; Google Tag Manager.
5
+
6
+ Features:-
7
+
8
+ Easy to install and use
9
+ 100% Free
10
+ 100% Open Source</description><notes>Initial Release</notes><authors><author><name>Mukesh Chapagain</name><user>chapagain</user><email>mukesh.chapagain@gmail.com</email></author></authors><date>2015-11-04</date><time>7:13:45</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="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="chapagain"><file name="googletagmanager.xml" hash="edd9dd09fa9056d95c1f5dbe4d4285e1"/></dir></dir><dir name="template"><dir name="chapagain"><dir name="googletagmanager"><file name="gtm.phtml" hash="cf9879c06807600d5fdd419b33801cc6"/></dir></dir></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Chapagain"><dir name="GoogleTagManager"><dir name="Model"><file name="Gtm.php" hash="7f07882f0aaa8cd020dbb7427f729d75"/></dir><dir name="controllers"><file name="IndexController.php" hash="64c01101a2e49ede280b6d98575ad09d"/></dir><dir name="etc"><file name="adminhtml.xml" hash="cb66c3eb20d2ed6e2694821a494981b7"/><file name="config.xml" hash="7343156644cf8dfa2135cf29d1c17b95"/><file name="system.xml" hash="acf0053e8484fbd60a1a3d27b563918c"/></dir><dir name="Helper"><file name="Data.php" hash="a11bae890f6ccc560cfa4e331caf8586"/></dir><dir name="Block"><file name="Gtm.php" hash="01318087b58aa7143c55c16d729ce559"/><dir name="System"><dir name="Config"><file name="Info.php" hash="0b212046f9a6c46b4d597e517343857f"/></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Chapagain_GoogleTagManager.xml" hash="0e919046e69f0db818bbcdfb013302b1"/></dir></dir></dir></target></contents></package>