Version Notes
The first stable version of Metrilo's integration with Magento
Download this release
Release Info
| Developer | Murry Ivanoff |
| Extension | Metrilo_Analytics |
| Version | 1.0.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0 to 1.0.1
app/code/community/Metrilo/Analytics/Helper/Data.php
CHANGED
|
@@ -54,14 +54,26 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 54 |
* @param string $type
|
| 55 |
* @param string|array $data
|
| 56 |
*/
|
| 57 |
-
public function addEvent($method, $type, $data)
|
| 58 |
{
|
| 59 |
-
$events =
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
'method' => $method,
|
| 62 |
'type' => $type,
|
| 63 |
'data' => $data
|
| 64 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
$this->getSession()->setData(Metrilo_Analytics_Block_Head::DATA_TAG, $events);
|
| 66 |
}
|
| 67 |
|
|
@@ -85,7 +97,7 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 85 |
);
|
| 86 |
|
| 87 |
if ($order->getCouponCode()) {
|
| 88 |
-
$data['coupons'] = $order->getCouponCode();
|
| 89 |
}
|
| 90 |
$skusAdded = array();
|
| 91 |
foreach ($order->getAllItems() as $item) {
|
| 54 |
* @param string $type
|
| 55 |
* @param string|array $data
|
| 56 |
*/
|
| 57 |
+
public function addEvent($method, $type, $data, $metaData = false)
|
| 58 |
{
|
| 59 |
+
$events = array();
|
| 60 |
+
|
| 61 |
+
if ($this->getSession()->getData(Metrilo_Analytics_Block_Head::DATA_TAG) != '') {
|
| 62 |
+
$events = (array)$this->getSession()->getData(Metrilo_Analytics_Block_Head::DATA_TAG);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
$eventToAdd = array(
|
| 66 |
'method' => $method,
|
| 67 |
'type' => $type,
|
| 68 |
'data' => $data
|
| 69 |
);
|
| 70 |
+
|
| 71 |
+
if ($metaData) {
|
| 72 |
+
$eventToAdd['metaData'] = $metaData;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
array_push($events, $eventToAdd);
|
| 76 |
+
|
| 77 |
$this->getSession()->setData(Metrilo_Analytics_Block_Head::DATA_TAG, $events);
|
| 78 |
}
|
| 79 |
|
| 97 |
);
|
| 98 |
|
| 99 |
if ($order->getCouponCode()) {
|
| 100 |
+
$data['coupons'] = array($order->getCouponCode());
|
| 101 |
}
|
| 102 |
$skusAdded = array();
|
| 103 |
foreach ($order->getAllItems() as $item) {
|
app/code/community/Metrilo/Analytics/Model/Observer.php
CHANGED
|
@@ -44,12 +44,30 @@ class Metrilo_Analytics_Model_Observer
|
|
| 44 |
{
|
| 45 |
$helper = Mage::helper('metrilo_analytics');
|
| 46 |
$action = $observer->getEvent()->getAction()->getFullActionName();
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
// homepage & CMS pages
|
| 49 |
if ($action == 'cms_index_index' || $action == 'cms_page_view') {
|
| 50 |
$title = Mage::getSingleton('cms/page')->getTitle();
|
| 51 |
-
$helper->addEvent('track', 'pageview', $title);
|
| 52 |
-
|
| 53 |
}
|
| 54 |
// category view pages
|
| 55 |
if($action == 'catalog_category_view') {
|
|
@@ -59,7 +77,7 @@ class Metrilo_Analytics_Model_Observer
|
|
| 59 |
'name' => $category->getName()
|
| 60 |
);
|
| 61 |
$helper->addEvent('track', 'view_category', $data);
|
| 62 |
-
|
| 63 |
}
|
| 64 |
// product view pages
|
| 65 |
if ($action == 'catalog_product_view') {
|
|
@@ -86,23 +104,35 @@ class Metrilo_Analytics_Model_Observer
|
|
| 86 |
$data['categories'] = $categories;
|
| 87 |
}
|
| 88 |
$helper->addEvent('track', 'view_product', $data);
|
| 89 |
-
|
| 90 |
}
|
| 91 |
// cart view
|
| 92 |
if($action == 'checkout_cart_index') {
|
| 93 |
$helper->addEvent('track', 'view_cart', array());
|
| 94 |
-
|
| 95 |
}
|
| 96 |
// checkout
|
| 97 |
if ($action != 'checkout_cart_index' && strpos($action, 'checkout') !== false && strpos($action, 'success') === false) {
|
| 98 |
$helper->addEvent('track', 'checkout_start', array());
|
| 99 |
-
|
| 100 |
}
|
|
|
|
| 101 |
// Any other pages
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
|
| 108 |
/**
|
|
@@ -200,6 +230,18 @@ class Metrilo_Analytics_Model_Observer
|
|
| 200 |
$order = $observer->getOrder();
|
| 201 |
if ($order->getId()) {
|
| 202 |
$data = $helper->prepareOrderDetails($order);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
$helper->addEvent('track', 'order', $data);
|
| 204 |
}
|
| 205 |
}
|
| 44 |
{
|
| 45 |
$helper = Mage::helper('metrilo_analytics');
|
| 46 |
$action = $observer->getEvent()->getAction()->getFullActionName();
|
| 47 |
+
|
| 48 |
+
if ($this->_isRejected($action)) {
|
| 49 |
+
return;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
// Catalog search pages
|
| 53 |
+
if ($action == 'catalogsearch_result_index') {
|
| 54 |
+
$query = Mage::helper('catalogsearch')->getQuery();
|
| 55 |
+
if ($text = $query->getQueryText()) {
|
| 56 |
+
$resultCount = Mage::app()->getLayout()->getBlock('search.result')->getResultCount();
|
| 57 |
+
$params = array(
|
| 58 |
+
'query' => $text,
|
| 59 |
+
'result_count' => $resultCount
|
| 60 |
+
);
|
| 61 |
+
$helper->addEvent('track', 'search', $params);
|
| 62 |
+
return;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
// homepage & CMS pages
|
| 67 |
if ($action == 'cms_index_index' || $action == 'cms_page_view') {
|
| 68 |
$title = Mage::getSingleton('cms/page')->getTitle();
|
| 69 |
+
$helper->addEvent('track', 'pageview', $title, array('backend_hook' => $action));
|
| 70 |
+
return;
|
| 71 |
}
|
| 72 |
// category view pages
|
| 73 |
if($action == 'catalog_category_view') {
|
| 77 |
'name' => $category->getName()
|
| 78 |
);
|
| 79 |
$helper->addEvent('track', 'view_category', $data);
|
| 80 |
+
return;
|
| 81 |
}
|
| 82 |
// product view pages
|
| 83 |
if ($action == 'catalog_product_view') {
|
| 104 |
$data['categories'] = $categories;
|
| 105 |
}
|
| 106 |
$helper->addEvent('track', 'view_product', $data);
|
| 107 |
+
return;
|
| 108 |
}
|
| 109 |
// cart view
|
| 110 |
if($action == 'checkout_cart_index') {
|
| 111 |
$helper->addEvent('track', 'view_cart', array());
|
| 112 |
+
return;
|
| 113 |
}
|
| 114 |
// checkout
|
| 115 |
if ($action != 'checkout_cart_index' && strpos($action, 'checkout') !== false && strpos($action, 'success') === false) {
|
| 116 |
$helper->addEvent('track', 'checkout_start', array());
|
| 117 |
+
return;
|
| 118 |
}
|
| 119 |
+
|
| 120 |
// Any other pages
|
| 121 |
+
$title = $observer->getEvent()->getLayout()->getBlock('head')->getTitle();
|
| 122 |
+
$helper->addEvent('track', 'pageview', $title, array('backend_hook' => $action));
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* Events that we don't want to track
|
| 127 |
+
*
|
| 128 |
+
* @param string event
|
| 129 |
+
*/
|
| 130 |
+
private function _isRejected(string $event)
|
| 131 |
+
{
|
| 132 |
+
return in_array(
|
| 133 |
+
$event,
|
| 134 |
+
array('catalogsearch_advanced_result', 'catalogsearch_advanced_index')
|
| 135 |
+
);
|
| 136 |
}
|
| 137 |
|
| 138 |
/**
|
| 230 |
$order = $observer->getOrder();
|
| 231 |
if ($order->getId()) {
|
| 232 |
$data = $helper->prepareOrderDetails($order);
|
| 233 |
+
if($order->getCustomerIsGuest()) {
|
| 234 |
+
$identify = array(
|
| 235 |
+
'id' => $order->getCustomerEmail(),
|
| 236 |
+
'params' => array(
|
| 237 |
+
'email' => $order->getCustomerEmail(),
|
| 238 |
+
'name' => $order->getCustomerFirstname(). ' '. $order->getCustomerLastname(),
|
| 239 |
+
'first_name' => $order->getCustomerFirstname(),
|
| 240 |
+
'last_name' => $order->getCustomerLastname(),
|
| 241 |
+
)
|
| 242 |
+
);
|
| 243 |
+
$helper->addEvent('identify', 'identify', $identify);
|
| 244 |
+
}
|
| 245 |
$helper->addEvent('track', 'order', $data);
|
| 246 |
}
|
| 247 |
}
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Metrilo_Analytics</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>Apache Software License (ASL)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -20,9 +20,9 @@
|
|
| 20 |
* Metrilo automatically collects and analyzes your eCommerce data to use for your email campaigns.</description>
|
| 21 |
<notes>The first stable version of Metrilo's integration with Magento</notes>
|
| 22 |
<authors><author><name>Murry Ivanoff</name><user>Metrilo</user><email>murry@metrilo.com</email></author><author><name>Miroslav Petrov</name><user>miro</user><email>miro91tn@gmail.com</email></author><author><name>Zhivko Draganov</name><user>zhivko</user><email>zhivko@metrilo.com</email></author></authors>
|
| 23 |
-
<date>2015-
|
| 24 |
-
<time>
|
| 25 |
-
<contents><target name="magecommunity"><dir name="Metrilo"><dir name="Analytics"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="70aadb3d62d998a3076bd4f9209db560"/></dir></dir></dir></dir><file name="Head.php" hash="7fc6870506f8882520b4e2b9596600d7"/></dir><dir name="Helper"><file name="Data.php" hash="
|
| 26 |
<compatible/>
|
| 27 |
<dependencies><required><php><min>5.2.1</min><max>5.6.22</max></php></required></dependencies>
|
| 28 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Metrilo_Analytics</name>
|
| 4 |
+
<version>1.0.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>Apache Software License (ASL)</license>
|
| 7 |
<channel>community</channel>
|
| 20 |
* Metrilo automatically collects and analyzes your eCommerce data to use for your email campaigns.</description>
|
| 21 |
<notes>The first stable version of Metrilo's integration with Magento</notes>
|
| 22 |
<authors><author><name>Murry Ivanoff</name><user>Metrilo</user><email>murry@metrilo.com</email></author><author><name>Miroslav Petrov</name><user>miro</user><email>miro91tn@gmail.com</email></author><author><name>Zhivko Draganov</name><user>zhivko</user><email>zhivko@metrilo.com</email></author></authors>
|
| 23 |
+
<date>2015-11-17</date>
|
| 24 |
+
<time>15:02:29</time>
|
| 25 |
+
<contents><target name="magecommunity"><dir name="Metrilo"><dir name="Analytics"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="70aadb3d62d998a3076bd4f9209db560"/></dir></dir></dir></dir><file name="Head.php" hash="7fc6870506f8882520b4e2b9596600d7"/></dir><dir name="Helper"><file name="Data.php" hash="4930ff4f95f3b80a7cfb7590e6d1ac44"/></dir><dir name="Model"><file name="Import.php" hash="1eb20cd00c210ee378039edb8d0515dc"/><file name="Observer.php" hash="720905b3bdff1d71df92e32fee81ae04"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AjaxController.php" hash="0a16196c1c62b3359508b0b688a36e04"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="00c90fdba5e48bb35367c16c83abd6a7"/><file name="config.xml" hash="4708aed8284ec5c1457ca08a5ae079f6"/><file name="system.xml" hash="7564c68e51df23d7975bc1c9ead7be8f"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="metrilo_analytics.xml" hash="0e6911e2e883992f2182969286d929b1"/></dir><dir name="template"><dir name="metrilo"><dir name="system"><dir name="config"><file name="button.phtml" hash="528d7eb52bf996b7b2a31e8c6a4d7d86"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="metrilo"><file name="favicon-metrilo.png" hash="743558f1e49a730be9d515197a36567b"/><file name="loader.gif" hash="e05e6bb35d035cac4f3e0c8af213e9ab"/><file name="logo.png" hash="e9e54afd81384e12f77aca4eaebf5be8"/><file name="styles.css" hash="da0c07513d917e4ad08ff50814b536e1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Metrilo_Analytics.xml" hash="3a4dbecc4e093537f11dd4c8fa2756e7"/></dir></target></contents>
|
| 26 |
<compatible/>
|
| 27 |
<dependencies><required><php><min>5.2.1</min><max>5.6.22</max></php></required></dependencies>
|
| 28 |
</package>
|
