Respondr_Ecommerce - Version 1.0.1

Version Notes

- Minor bug fix to get ecommerce orders tracking correctly.
- Added support for syncing optin status with Respondr.

Download this release

Release Info

Developer Leroy Ware
Extension Respondr_Ecommerce
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/RespondrMage/RespondrAnalytics/Block/Respondr.php ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Respondr Extension for Magento created by Respondr Inc.
5
+ * Based on Piwik Extension for Magento by Adrian Speyer
6
+ *
7
+ * @category RespondrMage
8
+ * @package RespondrMage_RespondrAnalytics
9
+ * @copyright Copyright (c) 2014 Respondr Inc. (http://www.respondr.io)
10
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
11
+ *
12
+ */
13
+
14
+ class RespondrMage_RespondrAnalytics_Block_Respondr extends Mage_Core_Block_Template
15
+ {
16
+
17
+ /**
18
+ * Get a specific page name (may be customized via layout)
19
+ *
20
+ * @return string|null
21
+ */
22
+ public function getPageName()
23
+ {
24
+ return $this->_getData('page_name');
25
+ }
26
+
27
+ /**
28
+ * Render information about specified orders and their items
29
+ * http://piwik.org/docs/ecommerce-analytics/
30
+ */
31
+ protected function _getOrdersTrackingCode()
32
+ {
33
+ $orderIds = $this->getOrderIds();
34
+ if (empty($orderIds) || !is_array($orderIds)) {
35
+ return;
36
+ }
37
+
38
+ $collection = Mage::getResourceModel('sales/order_collection')
39
+ ->addFieldToFilter('entity_id', array('in' => $orderIds));
40
+ $result = array();
41
+
42
+ foreach ($collection as $order) {
43
+ foreach ($order->getAllVisibleItems() as $item) {
44
+
45
+ //get category name
46
+ $product_id = $item->product_id;
47
+ $_product = Mage::getModel('catalog/product')->load($product_id);
48
+ $cats = $_product->getCategoryIds();
49
+ $category_id = $cats[0]; // just grab the first id
50
+ $category = Mage::getModel('catalog/category')->load($category_id);
51
+ $category_name = $category->getName();
52
+
53
+
54
+ if ($item->getQtyOrdered()) {
55
+ $qty = number_format($item->getQtyOrdered(), 0, '.', '');
56
+ } else {
57
+ $qty = '0';
58
+ }
59
+ $result[] = sprintf("respondrTracker.addEcommerceItem( '%s', '%s', '%s', %s, %s);",
60
+ $this->jsQuoteEscape($item->getSku()),
61
+ $this->jsQuoteEscape($item->getName()),
62
+ $category_name,
63
+ $item->getBasePrice(),
64
+ $qty
65
+ );
66
+
67
+ }
68
+ foreach ($collection as $order) {
69
+ if ($order->getGrandTotal()) {
70
+ $subtotal = $order->getGrandTotal() - $order->getShippingAmount() - $order->getShippingTaxAmount();
71
+ } else {
72
+ $subtotal = '0.00';
73
+ }
74
+ $result[] = sprintf("respondrTracker.trackEcommerceOrder( '%s', %s, %s, %s, %s);",
75
+ $order->getIncrementId(),
76
+ $order->getBaseGrandTotal(),
77
+ $subtotal,
78
+ $order->getBaseTaxAmount(),
79
+ $order->getBaseShippingAmount()
80
+ );
81
+
82
+
83
+ }
84
+ }
85
+ return implode("\n", $result);
86
+ }
87
+
88
+ /**
89
+ * Render information when cart updated
90
+ * http://piwik.org/docs/ecommerce-analytics/
91
+ */
92
+ protected function _getEcommerceCartUpdate()
93
+ {
94
+
95
+ $cart = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
96
+
97
+ foreach ($cart as $cartitem) {
98
+
99
+ //get category name
100
+ $product_id = $cartitem->product_id;
101
+ $_product = Mage::getModel('catalog/product')->load($product_id);
102
+ $cats = $_product->getCategoryIds();
103
+ if (isset($cats)) {
104
+ $category_id = $cats[0];
105
+ } // just grab the first id
106
+ $category = Mage::getModel('catalog/category')->load($category_id);
107
+ $category_name = $category->getName();
108
+ $nameofproduct = $cartitem->getName();
109
+ $nameofproduct = str_replace('"', "", $nameofproduct);
110
+
111
+ if ($cartitem->getPrice() == 0 || $cartitem->getPrice() < 0.00001):
112
+ continue;
113
+ endif;
114
+ echo 'respondrTracker.addEcommerceItem("' . $cartitem->getSku() . '","' . $nameofproduct . '","' . $category_name . '",' . $cartitem->getPrice() . ',' . $cartitem->getQty() . ');';
115
+ echo "\n";
116
+ }
117
+
118
+ //total in cart
119
+ $grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();
120
+ if ($grandTotal == 0) echo ''; else
121
+ echo 'respondrTracker.trackEcommerceCartUpdate(' . $grandTotal . ');';
122
+ echo "\n";
123
+ }
124
+
125
+ /**
126
+ * Render information when product page view
127
+ * http://piwik.org/docs/ecommerce-analytics/
128
+ */
129
+ protected function _getProductPageview()
130
+ {
131
+
132
+ $currentproduct = Mage::registry('current_product');
133
+
134
+ if (!($currentproduct instanceof Mage_Catalog_Model_Product)) {
135
+ return;
136
+ }
137
+
138
+
139
+ $product_id = $currentproduct->getId();
140
+ $_product = Mage::getModel('catalog/product')->load($product_id);
141
+ $cats = $_product->getCategoryIds();
142
+ $category_id = $cats[0]; // just grab the first id
143
+ //$category_id = if (isset($cats[0]) {$category_id = $cats[0]} else $category_id = null; potential fix when no catgeories
144
+ $category = Mage::getModel('catalog/category')->load($category_id);
145
+ $category_name = $category->getName();
146
+ $product = $currentproduct->getName();
147
+ $product = str_replace('"', "", $product);
148
+ $description = str_replace('"', "", $_product->getDescription());
149
+
150
+ echo 'respondrTracker.setEcommerceView("' . $currentproduct->getSku() . '", "' . $product . '","' . $category_name . '",' . $currentproduct->getPrice() . ',"'. $_product->getImageUrl() . '","'. $description .'");';
151
+ Mage::unregister('current_category');
152
+ }
153
+
154
+ /**
155
+ * Render information of category view
156
+ * http://piwik.org/docs/ecommerce-analytics/
157
+ */
158
+ protected function _getCategoryPageview()
159
+ {
160
+ $currentcategory = Mage::registry('current_category');
161
+
162
+ if (!($currentcategory instanceof Mage_Catalog_Model_Category)) {
163
+ return;
164
+ }
165
+ echo 'respondrTracker.setEcommerceView(false,false,"' . $currentcategory->getName() . '",false,false);';
166
+ Mage::unregister('current_product');
167
+ }
168
+
169
+ /**
170
+ * Respondr lead/customer capture...
171
+ * Saves user's firstname, lastname, company, email, telephone
172
+ * and optin status as json-encoded custom variable
173
+ */
174
+ protected function _getUser() {
175
+
176
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
177
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
178
+ $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling();
179
+ $optin = Mage::helper('respondranalytics')->isCustomerSubscribed($customer->getData("email"));
180
+ echo 'respondrTracker.setCustomVariable (1, "email", "'.$customer->getData("email").'", scope = "visit");';
181
+ echo 'respondrTracker.setCustomVariable (2, "firstName", "'.$customer->getData("firstname").'", scope = "visit");';
182
+ echo 'respondrTracker.setCustomVariable (3, "lastName", "'.$customer->getData("lastname").'", scope = "visit");';
183
+ if ($customerAddressId){
184
+ $address = Mage::getModel('customer/address')->load($customerAddressId);
185
+ echo 'respondrTracker.setCustomVariable (4, "company", "'.$address->getData("company").'", scope = "visit");';
186
+ echo 'respondrTracker.setCustomVariable (5, "phone", "'.$address->getData("telephone").'", scope = "visit");';
187
+ }
188
+ }
189
+
190
+
191
+ }
192
+
193
+ protected function _getOptinStatus() {
194
+
195
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
196
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
197
+ $optin = Mage::helper('respondranalytics')->isCustomerSubscribed($customer->getData("email"));
198
+ echo 'respondrTracker.setCustomVariable (10, "optin", "'.$optin.'", scope = "visit");';
199
+ }
200
+
201
+
202
+ }
203
+
204
+ /**
205
+ * Render Respondr tracking scripts
206
+ *
207
+ * @return string
208
+ */
209
+ protected function _toHtml()
210
+ {
211
+ if (!Mage::helper('respondranalytics')->isRespondrAnalyticsAvailable()) {
212
+ return '';
213
+ }
214
+
215
+ return parent::_toHtml();
216
+ }
217
+ }
app/code/community/RespondrMage/RespondrAnalytics/Helper/Data.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Respondr Extension for Magento created by Respondr Inc.
5
+ * Based on Piwik Extension for Magento by Adrian Speyer
6
+ *
7
+ * @category RespondrMage
8
+ * @package RespondrMage_RespondrAnalytics
9
+ * @copyright Copyright (c) 2014 Respondr Inc. (http://www.respondr.io)
10
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
11
+ *
12
+ */
13
+ class RespondrMage_RespondrAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
14
+ {
15
+ /**
16
+ * Config paths for using throughout the code
17
+ */
18
+ const XML_PATH_ACTIVE = 'respondr/analytics/active';
19
+ const XML_PATH_SITE = 'respondr/analytics/site';
20
+ const XML_PATH_PWTOKEN = 'respondr/analytics/pwtoken';
21
+
22
+ // hard-code Respondr URL
23
+ const SERVER_URL = 'http://analytics.respondr.io';
24
+
25
+
26
+ /**
27
+ *
28
+ * @param mixed $store
29
+ * @return bool
30
+ */
31
+ public function isRespondrAnalyticsAvailable($store = null)
32
+ {
33
+ $siteId = Mage::getStoreConfig(self::XML_PATH_SITE, $store);
34
+ return $siteId && Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $store);
35
+ }
36
+
37
+ /**
38
+ * Check the customer's newsletter optin status
39
+ * @return string
40
+ */
41
+ public function isCustomerSubscribed($email) {
42
+ $isSubscribed = 0;
43
+ $db = Mage::getSingleton('core/resource')->getConnection('core_read');
44
+ $sql = "SELECT * FROM `newsletter_subscriber` WHERE `subscriber_email`='".$email."' AND `subscriber_status`='1' LIMIT 1";
45
+ $result = $db->fetchAll($sql);
46
+ if($result){
47
+ $isSubscribed = 1;
48
+ }
49
+ return $isSubscribed;
50
+ }
51
+ }
app/code/community/RespondrMage/RespondrAnalytics/Model/Observer.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Respondr Extension for Magento created by Respondr Inc.
5
+ * Based on Piwik Extension for Magento by Adrian Speyer
6
+ *
7
+ * @category RespondrMage
8
+ * @package RespondrMage_RespondrAnalytics
9
+ * @copyright Copyright (c) 2014 Respondr Inc. (http://www.respondr.io)
10
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
11
+ *
12
+ */
13
+
14
+ class RespondrMage_RespondrAnalytics_Model_Observer
15
+ {
16
+
17
+
18
+ /**
19
+ * Add order information into Respondr block to render on checkout success pages
20
+ *
21
+ * @param Varien_Event_Observer $observer
22
+ */
23
+ public function setRespondrAnalyticsOnOrderSuccessPageView(Varien_Event_Observer $observer)
24
+ {
25
+ $orderIds = $observer->getEvent()->getOrderIds();
26
+ if (empty($orderIds) || !is_array($orderIds)) {
27
+ return;
28
+ }
29
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('respondr_analytics');
30
+ if ($block) {
31
+ $block->setOrderIds($orderIds);
32
+ }
33
+ }
34
+
35
+
36
+
37
+ }
38
+
39
+
app/code/community/RespondrMage/RespondrAnalytics/controllers/IndexController.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Respondr Extension for Magento created by Respondr Inc.
5
+ * Based on Piwik Extension for Magento by Adrian Speyer
6
+ *
7
+ * @category RespondrMage
8
+ * @package RespondrMage_RespondrAnalytics
9
+ * @copyright Copyright (c) 2014 Respondr Inc. (http://www.respondr.io)
10
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
11
+ *
12
+ */
13
+
14
+ class RespondrMage_RespondrAnalytics_IndexController extends Mage_Adminhtml_Controller_Action
15
+ {
16
+ public function indexAction()
17
+ {
18
+
19
+ $this->loadLayout();
20
+
21
+ $active = Mage::getStoreConfig(RespondrMage_RespondrAnalytics_Helper_Data::XML_PATH_ACTIVE);
22
+ $siteId = Mage::getStoreConfig(RespondrMage_RespondrAnalytics_Helper_Data::XML_PATH_SITE);
23
+ $pwtoken= Mage::getStoreConfig(RespondrMage_RespondrAnalytics_Helper_Data::XML_PATH_PWTOKEN);
24
+
25
+ $installPath = RespondrMage_RespondrAnalytics_Helper_Data::SERVER_URL;
26
+
27
+ if (!empty($pwtoken)){
28
+ $block = $this->getLayout()->createBlock('core/text', 'respondr-block')->setText('<iframe src="'.$installPath.'/index.php?module=Widgetize&action=iframe&moduleToWidgetize=Dashboard&actionToWidgetize=index&idSite='.$siteId.'&period=week&date=yesterday&token_auth='.$pwtoken.'" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="1000px"></iframe>');
29
+ $this->_addContent($block);
30
+ $this->_setActiveMenu('respondr_menu')->renderLayout();
31
+ }
32
+
33
+
34
+ if (empty($pwtoken)){
35
+ $block = $this->getLayout()->createBlock('core/text', 'respondr-block')->setText('You are missing your Piwik Token Auth Key. Get it from your API tab in your Piwik Install.');
36
+ $this->_addContent($block);
37
+ $this->_setActiveMenu('respondr_menu')->renderLayout();
38
+ }
39
+
40
+ }
41
+ }
app/code/community/RespondrMage/RespondrAnalytics/etc/adminhtml.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * Respondr Extension for Magento created by Adrian Speyer
6
+ * Get Respondr at http://www.respondr.org - Open source web analytics
7
+ *
8
+ * @category Mage
9
+ * @package Mage_RespoNdranalytics_etc_adminhtml
10
+ * @copyright Copyright (c) 2012 Adrian Speyer. (http://www.adrianspeyer.com)
11
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
12
+ *
13
+ */
14
+ -->
15
+ <config>
16
+ <menu>
17
+ <report translate="title" module="reports">
18
+ <title>Reports</title>
19
+ <sort_order>80</sort_order>
20
+ <children>
21
+ <iframe_respondr translate="title" module="reports">
22
+ <title>Respondr iFrame</title>
23
+ <sort_order>99999</sort_order>
24
+ <action>respondranalytics/index/index</action>
25
+ <depends><config>respondr/analytics/active</config></depends>
26
+ </iframe_respondr>
27
+ </children>
28
+ </report>
29
+ </menu>
30
+
31
+ <acl>
32
+ <resources>
33
+ <admin>
34
+ <children>
35
+ <system>
36
+ <children>
37
+ <config>
38
+ <children>
39
+ <respondr translate="title" module="respondranalytics">
40
+ <title>Respondr Analytics</title>
41
+ </respondr>
42
+ </children>
43
+ </config>
44
+ </children>
45
+ </system>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ <acl>
51
+ <resources>
52
+ <admin>
53
+ <children>
54
+ <report translate="title" module="reports">
55
+ <title>Reports</title>
56
+ <sort_order>80</sort_order>
57
+ <children>
58
+ <iframe_respondr translate="title">
59
+ <title>Respondr Iframe</title>
60
+ </iframe_respondr>
61
+ </children>
62
+ </report>
63
+ <system>
64
+ <children>
65
+ <config>
66
+ <children>
67
+ <reports translate="title" module="reports">
68
+ <title>Reports</title>
69
+ </reports>
70
+ </children>
71
+ </config>
72
+ </children>
73
+ </system>
74
+ </children>
75
+ </admin>
76
+ </resources>
77
+ </acl>
78
+ </config>
app/code/community/RespondrMage/RespondrAnalytics/etc/config.xml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * Piwik Extension for Magento created by Adrian Speyer
6
+ * Get Piwik at http://www.piwik.org - Open source web analytics
7
+ *
8
+ * @category PiwikMage
9
+ * @package RespondrMage_RespondrAnalytics
10
+ * @copyright Copyright (c) 2012 Adrian Speyer. (http://www.adrianspeyer.com)
11
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
12
+ *
13
+ */
14
+ -->
15
+ <config>
16
+ <modules>
17
+ <RespondrMage_RespondrAnalytics>
18
+ <version>1.0.0.0</version>
19
+ </RespondrMage_RespondrAnalytics>
20
+ </modules>
21
+ <global>
22
+ <models>
23
+ <respondranalytics>
24
+ <class>RespondrMage_RespondrAnalytics_Model</class>
25
+ </respondranalytics>
26
+ </models>
27
+ <blocks>
28
+ <respondranalytics>
29
+ <class>RespondrMage_RespondrAnalytics_Block</class>
30
+ </respondranalytics>
31
+ </blocks>
32
+ <helpers>
33
+ <respondranalytics>
34
+ <class>RespondrMage_RespondrAnalytics_Helper</class>
35
+ </respondranalytics>
36
+ </helpers>
37
+ </global>
38
+ <frontend>
39
+ <translate>
40
+ <modules>
41
+ <RespondrMage_RespondrAnalytics>
42
+ <files>
43
+ <default>RespondrMage_RespondrAnalytics.csv</default>
44
+ </files>
45
+ </RespondrMage_RespondrAnalytics>
46
+ </modules>
47
+ </translate>
48
+ <events>
49
+ <checkout_onepage_controller_success_action>
50
+ <observers>
51
+ <respondranalytics_order_success>
52
+ <class>respondranalytics/observer</class>
53
+ <method>setRespondrAnalyticsOnOrderSuccessPageView</method>
54
+ </respondranalytics_order_success>
55
+ </observers>
56
+ </checkout_onepage_controller_success_action>
57
+ <checkout_multishipping_controller_success_action>
58
+ <observers>
59
+ <respondranalytics_order_success>
60
+ <class>respondranalytics/observer</class>
61
+ <method>setRespondrAnalyticsOnOrderSuccessPageView</method>
62
+ </respondranalytics_order_success>
63
+ </observers>
64
+ </checkout_multishipping_controller_success_action>
65
+ </events>
66
+ <layout>
67
+ <updates>
68
+ <respondranalytics>
69
+ <file>respondranalytics.xml</file>
70
+ </respondranalytics>
71
+ </updates>
72
+ </layout>
73
+ </frontend>
74
+ <adminhtml>
75
+ <translate>
76
+ <modules>
77
+ <RespondrMage_RespondrAnalytics>
78
+ <files>
79
+ <default>RespondrMage_RespondrAnalytics.csv</default>
80
+ </files>
81
+ </RespondrMage_RespondrAnalytics>
82
+ </modules>
83
+ </translate>
84
+ </adminhtml>
85
+ <admin>
86
+ <routers>
87
+ <RespondrMage_RespondrAnalytics>
88
+ <use>admin</use>
89
+ <args>
90
+ <module>RespondrMage_RespondrAnalytics</module>
91
+ <frontName>respondranalytics</frontName>
92
+ </args>
93
+ </RespondrMage_RespondrAnalytics>
94
+ </routers>
95
+ </admin>
96
+ </config>
app/code/community/RespondrMage/RespondrAnalytics/etc/system.xml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * Respondr Extension for Magento created by Adrian Speyer
6
+ * Get Respondr at http://www.respondr.org - Open source web analytics
7
+ *
8
+ * @category RespondrMage
9
+ * @package RespondrMage_RespondrAnalytics
10
+ * @copyright Copyright (c) 2012 Adrian Speyer. (http://www.adrianspeyer.com)
11
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
12
+ *
13
+ */
14
+ -->
15
+ <config>
16
+ <sections>
17
+ <respondr translate="label" module="respondranalytics">
18
+ <label>Respondr</label>
19
+ <tab>sales</tab>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>350</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
+ <groups>
26
+ <analytics translate="label">
27
+ <label>Settings</label>
28
+ <frontend_type>text</frontend_type>
29
+ <comment>Don't have a Respondr account? Create one at <![CDATA[<a href="http://respondr.io/" target="_blank">www.respondr.io</a>]]></comment>
30
+ <sort_order>10</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <fields>
35
+ <active translate="label">
36
+ <label>Enable</label>
37
+ <frontend_type>select</frontend_type>
38
+ <source_model>adminhtml/system_config_source_yesno</source_model>
39
+ <sort_order>10</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </active>
44
+
45
+ <site translate="label">
46
+ <label>Site Id</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>30</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </site>
53
+
54
+
55
+ <pwtoken translate="label">
56
+ <label>Auth Token</label>
57
+ <comment>To find your Site Id and Auth Token, log in to Respondr.io and go to Account Settings -> Sites.</comment>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>40</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </pwtoken>
64
+
65
+
66
+ </fields>
67
+ </analytics>
68
+ </groups>
69
+ </respondr>
70
+ </sections>
71
+ </config>
app/design/frontend/base/default/layout/respondranalytics.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ *
4
+ * Respondr Extension for Magento created by Respondr Inc.
5
+ * Based on Piwik Extension for Magento by Adrian Speyer
6
+ *
7
+ * @category RespondrMage
8
+ * @package RespondrMage_RespondrAnalytics
9
+ * @copyright Copyright (c) 2014 Respondr Inc. (http://www.respondr.io)
10
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
11
+ *
12
+ -->
13
+ <layout version="0.1.0">
14
+
15
+ <!--
16
+ Default layout, loads most of the pages
17
+ -->
18
+
19
+ <default>
20
+ <reference name="before_body_end">
21
+ <block type="respondranalytics/respondr" name="respondr_analytics" as="respondr_analytics" template="respondranalytics/respondr.phtml" />
22
+ </reference>
23
+ </default>
24
+ </layout>
app/design/frontend/base/default/template/respondranalytics/respondr.phtml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Respondr Extension for Magento created by Respondr Inc.
5
+ * Based on Piwik Extension for Magento by Adrian Speyer
6
+ *
7
+ * @category RespondrMage
8
+ * @package RespondrMage_RespondrAnalytics
9
+ * @copyright Copyright (c) 2014 Respondr Inc. (http://www.respondr.io)
10
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
11
+ *
12
+ */
13
+ ?>
14
+ <?php if (!Mage::helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
15
+ <?php $siteId = Mage::getStoreConfig(RespondrMage_RespondrAnalytics_Helper_Data::XML_PATH_SITE) ?>
16
+ <?php $installPath = RespondrMage_RespondrAnalytics_Helper_Data::SERVER_URL ?>
17
+
18
+ <?php
19
+
20
+ if ($siteId) {
21
+ if (strpos($installPath, "https://") !== false) {
22
+ $secureinstallPath = $installPath;
23
+ $installPath = str_replace("https://", "http://", $installPath);
24
+ }
25
+ if (strpos($installPath, "http://") === false)
26
+ $installPath = "http://" . $installPath;
27
+
28
+ $secureinstallPath = str_replace("http://", "https://", $installPath);
29
+
30
+ $last = $installPath[strlen($installPath)-1];
31
+
32
+ if ($last != "/") {
33
+ $installPath .= "/";
34
+ $secureinstallPath .= "/";
35
+ }
36
+ ?>
37
+
38
+ <?php
39
+ //0 Search Results
40
+ if($this->getRequest()->getControllerName()=='result')
41
+ {
42
+ $nores = Mage::helper('catalogsearch')->getEngine()->getResultCollection()->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText())->getSize();
43
+ }?>
44
+
45
+
46
+
47
+ <!-- RESPONDR TRACKING CODE -->
48
+ <script type="text/javascript">
49
+ //<![CDATA[
50
+
51
+ var rBaseURL = (("https:" == document.location.protocol) ? "<?php echo $secureinstallPath ?>" : "<?php echo $installPath ?>");
52
+ document.write(unescape("%3Cscript src='" + rBaseURL + "respondr.js' type='text/javascript'%3E%3C/script%3E"));
53
+ </script><script type="text/javascript">
54
+ try {
55
+ var respondrTracker = Piwik.getTracker(rBaseURL + "respondr.php", <?php echo $siteId ?>);
56
+ <?php echo $this->_getEcommerceCartUpdate()?>
57
+ <?php echo $this->_getOrdersTrackingCode()?>
58
+ <?php echo $this->_getProductPageview()?>
59
+ <?php echo $this->_getCategoryPageview()?>
60
+ <?php echo $this->_getUser()?> // added by Respondr
61
+ <?php echo $this->_getOptinStatus()?> // added by Respondr
62
+ <?php if (isset($nores))
63
+ {?>
64
+ var searchCount = <? echo $nores?>;
65
+ respondrTracker.setCustomUrl(document.URL + '&search_count=' + searchCount);
66
+ <?php }?>
67
+
68
+ <?php
69
+ //404 tracking
70
+ $action = Mage::app()->getRequest()->getActionName();
71
+ if($action == 'noRoute'){?>
72
+ respondrTracker.setDocumentTitle('404/URL = '+String(document.location.pathname+document.location.search).replace(/\//g,"%2f") + '/From = ' + String(document.referrer).replace(/\//g,"%2f"));
73
+ <?php }?>
74
+
75
+ <?php echo "\n";?>
76
+ respondrTracker.trackPageView();
77
+ respondrTracker.enableLinkTracking();
78
+ } catch( err ) {}
79
+ //]]>
80
+ </script>
81
+ <noscript><p><img src="<?php echo $installPath ?>respondr.php?idsite=<?php echo $siteId ?>" style="border:0" alt="" /></p></noscript>
82
+ <!-- END RESPONDR TRACKING CODE -->
83
+
84
+ <?php } ?>
85
+ <?php endif; ?>
86
+
87
+
app/etc/modules/RespondrMage_RespondrAnalytics.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * Respondr Extension for Magento created by Respondr Inc.
6
+ * Based on Piwik Extension for Magento by Adrian Speyer
7
+ *
8
+ * @category RespondrMage
9
+ * @package RespondrMage_RespondrAnalytics
10
+ * @copyright Copyright (c) 2014 Respondr Inc. (http://www.respondr.io)
11
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
12
+ *
13
+ */
14
+ -->
15
+
16
+ <config>
17
+ <modules>
18
+ <RespondrMage_RespondrAnalytics>
19
+ <active>true</active>
20
+ <codePool>community</codePool>
21
+ <depends>
22
+ <Mage_Core/>
23
+ </depends>
24
+ </RespondrMage_RespondrAnalytics>
25
+ </modules>
26
+ </config>
app/locale/de_DE/RespondrMage_RespondrAnalytics.csv ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ "Site Id","Seiten-ID"
2
+ "Install Path","Installationspfad"
3
+ "Enable","Aktivieren"
4
+ "Respondr Analytics Control","Respondr Analytics Control"
5
+ "Respondr Analytics","Respondr Analytics"
app/locale/en_US/RespondrMage_RespondrAnalytics.csv ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ "Site Id","Site Id"
2
+ "Install Path","Install Path"
3
+ "Enable","Enable"
4
+ "Respondr Analytics Control","Respondr Analytics Control"
5
+ "Respondr Analytics","Respondr Analytics"
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Respondr_Ecommerce</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="@license http://www.gnu.org/licenses/gpl-3.0.html">GPL v3</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Advanced ecommerce marketing automation for Magento retailers.</summary>
10
  <description>Increase your online revenue with automated email, mobile, and social messaging driven by your web analytics. Respondr makes it easy to re-engage your customers and bring them back to your store. Creating and managing abandoned cart, product recommendation, and cross-sell email marketing has never been easier. You can also send coupons and promotions via SMS/MMS, Facebook and more!</description>
11
- <notes>This extension is based on Adrian Speyer's magento extension for Piwik, which can be found at http://www.magentocommerce.com/magento-connect/piwik-ecommerce.html.</notes>
12
- <authors><author><name>Leroy Ware</name><user>leroyjware</user><email>leroy@respondr.io</email></author></authors>
13
- <date>2014-04-29</date>
14
- <time>21:56:46</time>
15
- <contents><target name="magecommunity"><dir name="app"><dir name="code"><dir name="community"><dir name="RespondrMage"><dir name="RespondrAnalytics"><dir name="Block"><file name="Respondr.php" hash=""/></dir><dir name="Helper"><file name="Data.php" hash=""/></dir><dir name="Model"><file name="Observer.php" hash=""/></dir><dir name="controllers"><file name="IndexController.php" hash=""/></dir><dir name="etc"><file name="adminhtml.xml" hash=""/><file name="config.xml" hash=""/><file name="system.xml" hash=""/></dir></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="app"><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="respondranalytics.xml" hash=""/></dir><dir name="template"><dir name="respondranalytics"><file name="respondr.phtml" hash=""/></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="app"><dir name="etc"><dir name="modules"><file name="RespondrMage_RespondrAnalytics.xml" hash=""/></dir></dir></dir></target><target name="magelocale"><dir name="app"><dir name="locale"><dir name="de_DE"><file name="RespondrMage_RespondrAnalytics.csv" hash=""/></dir><dir name="en_US"><file name="RespondrMage_RespondrAnalytics.csv" hash=""/></dir></dir></dir></target></contents>
 
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Respondr_Ecommerce</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="@license http://www.gnu.org/licenses/gpl-3.0.html">GPL v3</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Advanced ecommerce marketing automation for Magento retailers.</summary>
10
  <description>Increase your online revenue with automated email, mobile, and social messaging driven by your web analytics. Respondr makes it easy to re-engage your customers and bring them back to your store. Creating and managing abandoned cart, product recommendation, and cross-sell email marketing has never been easier. You can also send coupons and promotions via SMS/MMS, Facebook and more!</description>
11
+ <notes>- Minor bug fix to get ecommerce orders tracking correctly.&#xD;
12
+ - Added support for syncing optin status with Respondr.</notes>
13
+ <authors><author><name>Leroy Ware</name><user>LeroyWare</user><email>leroy@respondr.io</email></author><author><name>Adrian Speyer</name><user>AdrianSpeyer</user><email>adriansprojects@gmail.com</email></author></authors>
14
+ <date>2014-07-03</date>
15
+ <time>11:16:28</time>
16
+ <contents><target name="magecommunity"><dir name="RespondrMage"><dir name="RespondrAnalytics"><dir name="Block"><file name="Respondr.php" hash="b95e0d1e80918a3f5c5cd3f957e79ba0"/></dir><dir name="Helper"><file name="Data.php" hash="be7c1f8d2fcdc4d3e7c1eb9612f9d6f8"/></dir><dir name="Model"><file name="Observer.php" hash="7301ca92b1762223cf8228439fa8468e"/></dir><dir name="controllers"><file name="IndexController.php" hash="c88824e1da8c803bb91d96505e99ce5b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="b28f4ddc5e0851cff79bdc1624e1192c"/><file name="config.xml" hash="ba0e13559f0515126ea5b169e6fa6ab2"/><file name="system.xml" hash="85e4eca7a0d8a78660c9f4222ca25633"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="respondranalytics.xml" hash="27dc170600cb1d71cdcb7bacb6455230"/></dir><dir name="template"><dir name="respondranalytics"><file name="respondr.phtml" hash="ed8662e33db2d7c4c5a9adae72a6b994"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RespondrMage_RespondrAnalytics.xml" hash="9dd32f4b236640c74d1f08f5cb8e344d"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="RespondrMage_RespondrAnalytics.csv" hash="788bc282a1e82ff83d93a70297435376"/></dir><dir name="en_US"><file name="RespondrMage_RespondrAnalytics.csv" hash="464c1c6e0ad748dadc01bf0a1e336287"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>