Version Notes
- fixed compatibility with PHP 5.2
- renamed configuration section from "OroCRM API" to "OroCRM"
Download this release
Release Info
Developer | Oro, Inc |
Extension | Oro_Tracking |
Version | 0.1.3 |
Comparing to | |
See all releases |
Code changes from version 0.1.2 to 0.1.3
- app/code/community/Oro/Tracking/Block/Tracking.php +37 -10
- app/code/community/Oro/Tracking/Helper/Data.php +4 -2
- app/code/community/Oro/Tracking/Model/Observer.php +31 -1
- app/code/community/Oro/Tracking/etc/config.xml +29 -1
- app/code/community/Oro/Tracking/etc/system.xml +1 -1
- app/design/frontend/base/default/template/orotracking/tracking.phtml +3 -1
- package.xml +6 -5
app/code/community/Oro/Tracking/Block/Tracking.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Oro Inc.
|
5 |
*
|
@@ -34,6 +33,7 @@ class Oro_Tracking_Block_Tracking extends Mage_Core_Block_Template
|
|
34 |
|
35 |
$data = array('id' => null, 'email' => null, 'visitor-id' => Mage::getSingleton('log/visitor')->getId());
|
36 |
if ($session->isLoggedIn()) {
|
|
|
37 |
$customer = $session->getCustomer();
|
38 |
$data = array_merge(
|
39 |
$data,
|
@@ -62,15 +62,15 @@ class Oro_Tracking_Block_Tracking extends Mage_Core_Block_Template
|
|
62 |
}
|
63 |
|
64 |
$collection = Mage::getResourceModel('sales/order_collection')
|
65 |
-
->
|
66 |
|
67 |
$result = array();
|
68 |
/** @var $order Mage_Sales_Model_Order */
|
69 |
foreach ($collection as $order) {
|
70 |
$result[] = sprintf(
|
71 |
-
"_paq.push(['trackEvent', 'OroCRM', 'Tracking', '%s', '%
|
72 |
Oro_Tracking_Helper_Data::EVENT_ORDER_PLACE_SUCCESS,
|
73 |
-
$order->
|
74 |
);
|
75 |
}
|
76 |
|
@@ -96,6 +96,8 @@ class Oro_Tracking_Block_Tracking extends Mage_Core_Block_Template
|
|
96 |
/** @var $quote Mage_Sales_Model_Quote */
|
97 |
$quote = Mage::getModel('checkout/session')->getQuote();
|
98 |
|
|
|
|
|
99 |
return sprintf(
|
100 |
"_paq.push(['trackEvent', 'OroCRM', 'Tracking', '%s', '%f' ]);",
|
101 |
Oro_Tracking_Helper_Data::EVENT_CHECKOUT_STARTED,
|
@@ -130,24 +132,49 @@ class Oro_Tracking_Block_Tracking extends Mage_Core_Block_Template
|
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
-
* Renders information about event on register
|
134 |
*
|
135 |
* @return string
|
136 |
*/
|
137 |
protected function _getCustomerEventsData()
|
138 |
{
|
139 |
-
$
|
140 |
|
141 |
-
|
142 |
-
|
|
|
143 |
|
144 |
-
|
145 |
"_paq.push(['trackEvent', 'OroCRM', 'Tracking', '%s', 1 ]);",
|
146 |
Oro_Tracking_Helper_Data::EVENT_REGISTRATION_FINISHED
|
147 |
);
|
148 |
}
|
149 |
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
|
153 |
/**
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Oro Inc.
|
4 |
*
|
33 |
|
34 |
$data = array('id' => null, 'email' => null, 'visitor-id' => Mage::getSingleton('log/visitor')->getId());
|
35 |
if ($session->isLoggedIn()) {
|
36 |
+
/** @var Mage_Customer_Model_Customer $customer */
|
37 |
$customer = $session->getCustomer();
|
38 |
$data = array_merge(
|
39 |
$data,
|
62 |
}
|
63 |
|
64 |
$collection = Mage::getResourceModel('sales/order_collection')
|
65 |
+
->addFieldToSearchFilter('entity_id', array('in' => $orderIds));
|
66 |
|
67 |
$result = array();
|
68 |
/** @var $order Mage_Sales_Model_Order */
|
69 |
foreach ($collection as $order) {
|
70 |
$result[] = sprintf(
|
71 |
+
"_paq.push(['trackEvent', 'OroCRM', 'Tracking', '%s', '%s' ]);",
|
72 |
Oro_Tracking_Helper_Data::EVENT_ORDER_PLACE_SUCCESS,
|
73 |
+
$order->getIncrementId()
|
74 |
);
|
75 |
}
|
76 |
|
96 |
/** @var $quote Mage_Sales_Model_Quote */
|
97 |
$quote = Mage::getModel('checkout/session')->getQuote();
|
98 |
|
99 |
+
//$quote->getOrigOrderId()
|
100 |
+
|
101 |
return sprintf(
|
102 |
"_paq.push(['trackEvent', 'OroCRM', 'Tracking', '%s', '%f' ]);",
|
103 |
Oro_Tracking_Helper_Data::EVENT_CHECKOUT_STARTED,
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
+
* Renders information about event on register/login/logout
|
136 |
*
|
137 |
* @return string
|
138 |
*/
|
139 |
protected function _getCustomerEventsData()
|
140 |
{
|
141 |
+
$result = array();
|
142 |
|
143 |
+
$coreSession = Mage::getSingleton('core/session');
|
144 |
+
if ($coreSession->getData('isJustRegistered')) {
|
145 |
+
$coreSession->unsetData('isJustRegistered');
|
146 |
|
147 |
+
$result[] = sprintf(
|
148 |
"_paq.push(['trackEvent', 'OroCRM', 'Tracking', '%s', 1 ]);",
|
149 |
Oro_Tracking_Helper_Data::EVENT_REGISTRATION_FINISHED
|
150 |
);
|
151 |
}
|
152 |
|
153 |
+
if ($coreSession->getData('isJustLoggedIn')) {
|
154 |
+
$customerSession = Mage::getModel('customer/session');
|
155 |
+
if ($customerSession->isLoggedIn()) {
|
156 |
+
$coreSession->unsetData('isJustLoggedIn');
|
157 |
+
$result[] = sprintf(
|
158 |
+
"_paq.push(['trackEvent', 'OroCRM', 'Tracking', '%s', %d ]);",
|
159 |
+
Oro_Tracking_Helper_Data::EVENT_CUSTOMER_LOGIN,
|
160 |
+
$customerSession->getCustomerId()
|
161 |
+
);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
if ($coreSession->getData('isJustLoggedOut')) {
|
166 |
+
$result[] = sprintf(
|
167 |
+
"_paq.push(['trackEvent', 'OroCRM', 'Tracking', '%s', %d ]);",
|
168 |
+
Oro_Tracking_Helper_Data::EVENT_CUSTOMER_LOGOUT,
|
169 |
+
$coreSession->getData('isJustLoggedOut')
|
170 |
+
);
|
171 |
+
$result[] = "_paq.push(['appendToTrackingUrl', 'new_visit=1']);";
|
172 |
+
$result[] = "_paq.push(['deleteCookies']);";
|
173 |
+
|
174 |
+
$coreSession->unsetData('isJustLoggedOut');
|
175 |
+
}
|
176 |
+
|
177 |
+
return empty($result) ? '' : implode("\n\r", $result);
|
178 |
}
|
179 |
|
180 |
/**
|
app/code/community/Oro/Tracking/Helper/Data.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Oro Inc.
|
5 |
*
|
@@ -16,6 +15,7 @@
|
|
16 |
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
17 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
*/
|
|
|
19 |
class Oro_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
|
20 |
{
|
21 |
const GUEST_USER_IDENTIFIER = 'guest';
|
@@ -23,7 +23,9 @@ class Oro_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
|
|
23 |
const EVENT_REGISTRATION_FINISHED = 'registration';
|
24 |
const EVENT_CART_ITEM_ADDED = 'cart item added';
|
25 |
const EVENT_CHECKOUT_STARTED = 'user entered checkout';
|
26 |
-
const EVENT_ORDER_PLACE_SUCCESS = 'order
|
|
|
|
|
27 |
|
28 |
const XML_PATH_ENABLED = 'oro/tracking/active';
|
29 |
const XML_PATH_HOST = 'oro/tracking/host';
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Oro Inc.
|
4 |
*
|
15 |
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
16 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
*/
|
18 |
+
|
19 |
class Oro_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
|
20 |
{
|
21 |
const GUEST_USER_IDENTIFIER = 'guest';
|
23 |
const EVENT_REGISTRATION_FINISHED = 'registration';
|
24 |
const EVENT_CART_ITEM_ADDED = 'cart item added';
|
25 |
const EVENT_CHECKOUT_STARTED = 'user entered checkout';
|
26 |
+
const EVENT_ORDER_PLACE_SUCCESS = 'order placed';
|
27 |
+
const EVENT_CUSTOMER_LOGIN = 'user logged in';
|
28 |
+
const EVENT_CUSTOMER_LOGOUT = 'user logged out';
|
29 |
|
30 |
const XML_PATH_ENABLED = 'oro/tracking/active';
|
31 |
const XML_PATH_HOST = 'oro/tracking/host';
|
app/code/community/Oro/Tracking/Model/Observer.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Oro Inc.
|
5 |
*
|
@@ -16,6 +15,7 @@
|
|
16 |
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
17 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
*/
|
|
|
19 |
class Oro_Tracking_Model_Observer
|
20 |
{
|
21 |
/**
|
@@ -45,6 +45,23 @@ class Oro_Tracking_Model_Observer
|
|
45 |
$session->setData('isJustRegistered', true);
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* Set product ID to session after product has been added
|
50 |
*
|
@@ -58,4 +75,17 @@ class Oro_Tracking_Model_Observer
|
|
58 |
$session = Mage::getSingleton('checkout/session');
|
59 |
$session->setData('justAddedProductId', $product->getId());
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Oro Inc.
|
4 |
*
|
15 |
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
16 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
*/
|
18 |
+
|
19 |
class Oro_Tracking_Model_Observer
|
20 |
{
|
21 |
/**
|
45 |
$session->setData('isJustRegistered', true);
|
46 |
}
|
47 |
|
48 |
+
/**
|
49 |
+
* @param Varien_Event_Observer $observer
|
50 |
+
*/
|
51 |
+
public function onOrderPlace(Varien_Event_Observer $observer)
|
52 |
+
{
|
53 |
+
/** @var $orderInstance Mage_Sales_Model_Order */
|
54 |
+
$orderInstance = $observer->getOrder();
|
55 |
+
|
56 |
+
/** @var Mage_Sales_Model_Quote $quote */
|
57 |
+
$quote = Mage::getModel('sales/quote')->load($orderInstance->getQuoteId());
|
58 |
+
|
59 |
+
$method = $quote->getCheckoutMethod(true);
|
60 |
+
if ($method === Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER) {
|
61 |
+
$this->onRegistrationSuccess();
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
/**
|
66 |
* Set product ID to session after product has been added
|
67 |
*
|
75 |
$session = Mage::getSingleton('checkout/session');
|
76 |
$session->setData('justAddedProductId', $product->getId());
|
77 |
}
|
78 |
+
|
79 |
+
public function onCustomerLoggedIn()
|
80 |
+
{
|
81 |
+
$session = Mage::getSingleton('core/session');
|
82 |
+
$session->setData('isJustLoggedIn', true);
|
83 |
+
}
|
84 |
+
|
85 |
+
public function onCustomerLoggedOut()
|
86 |
+
{
|
87 |
+
$coreSession = Mage::getSingleton('core/session');
|
88 |
+
$customerSession = Mage::getSingleton('customer/session');
|
89 |
+
$coreSession->setData('isJustLoggedOut', $customerSession->getCustomerId());
|
90 |
+
}
|
91 |
}
|
app/code/community/Oro/Tracking/etc/config.xml
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Oro_Tracking>
|
23 |
-
<version>0.1.
|
24 |
</Oro_Tracking>
|
25 |
</modules>
|
26 |
<global>
|
@@ -66,6 +66,14 @@
|
|
66 |
</orotracking_order_success>
|
67 |
</observers>
|
68 |
</checkout_multishipping_controller_success_action>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
<!-- Registration success events -->
|
71 |
<customer_register_success>
|
@@ -86,6 +94,26 @@
|
|
86 |
</orotracking_cart_item_add>
|
87 |
</observers>
|
88 |
</checkout_cart_add_product_complete>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
</events>
|
90 |
</frontend>
|
91 |
</config>
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Oro_Tracking>
|
23 |
+
<version>0.1.3</version>
|
24 |
</Oro_Tracking>
|
25 |
</modules>
|
26 |
<global>
|
66 |
</orotracking_order_success>
|
67 |
</observers>
|
68 |
</checkout_multishipping_controller_success_action>
|
69 |
+
<sales_order_place_after>
|
70 |
+
<observers>
|
71 |
+
<orotracking_order_place_before>
|
72 |
+
<class>oro_tracking/observer</class>
|
73 |
+
<method>onOrderPlace</method>
|
74 |
+
</orotracking_order_place_before>
|
75 |
+
</observers>
|
76 |
+
</sales_order_place_after>
|
77 |
|
78 |
<!-- Registration success events -->
|
79 |
<customer_register_success>
|
94 |
</orotracking_cart_item_add>
|
95 |
</observers>
|
96 |
</checkout_cart_add_product_complete>
|
97 |
+
|
98 |
+
<!-- Customer logged in event -->
|
99 |
+
<customer_login>
|
100 |
+
<observers>
|
101 |
+
<orotracking_customer_logged_in>
|
102 |
+
<class>oro_tracking/observer</class>
|
103 |
+
<method>onCustomerLoggedIn</method>
|
104 |
+
</orotracking_customer_logged_in>
|
105 |
+
</observers>
|
106 |
+
</customer_login>
|
107 |
+
|
108 |
+
<!-- Customer logged out event -->
|
109 |
+
<customer_logout>
|
110 |
+
<observers>
|
111 |
+
<orotracking_customer_logged_out>
|
112 |
+
<class>oro_tracking/observer</class>
|
113 |
+
<method>onCustomerLoggedOut</method>
|
114 |
+
</orotracking_customer_logged_out>
|
115 |
+
</observers>
|
116 |
+
</customer_logout>
|
117 |
</events>
|
118 |
</frontend>
|
119 |
</config>
|
app/code/community/Oro/Tracking/etc/system.xml
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
<config>
|
21 |
<sections>
|
22 |
<oro translate="label" module="oro_tracking">
|
23 |
-
<label>OroCRM
|
24 |
<tab>customer</tab>
|
25 |
<frontend_type>text</frontend_type>
|
26 |
<sort_order>600</sort_order>
|
20 |
<config>
|
21 |
<sections>
|
22 |
<oro translate="label" module="oro_tracking">
|
23 |
+
<label>OroCRM</label>
|
24 |
<tab>customer</tab>
|
25 |
<frontend_type>text</frontend_type>
|
26 |
<sort_order>600</sort_order>
|
app/design/frontend/base/default/template/orotracking/tracking.phtml
CHANGED
@@ -26,12 +26,14 @@ $helper = Mage::helper('oro_tracking');
|
|
26 |
var _paq = _paq || [];
|
27 |
_paq.push(['setUserId', "<?php echo $this->_getUserIdentifier(); ?>"]);
|
28 |
_paq.push(['setConversionAttributionFirstReferrer', false]);
|
|
|
|
|
|
|
29 |
_paq.push(['trackPageView']);
|
30 |
|
31 |
<?php echo $this->_getOrderEventsData(); ?>
|
32 |
<?php echo $this->_getCheckoutEventsData(); ?>
|
33 |
<?php echo $this->_getCartEventsData(); ?>
|
34 |
-
<?php echo $this->_getCustomerEventsData(); ?>
|
35 |
|
36 |
(function() {
|
37 |
var u="<?php echo $helper->getHost(); ?>";
|
26 |
var _paq = _paq || [];
|
27 |
_paq.push(['setUserId', "<?php echo $this->_getUserIdentifier(); ?>"]);
|
28 |
_paq.push(['setConversionAttributionFirstReferrer', false]);
|
29 |
+
|
30 |
+
<?php echo $this->_getCustomerEventsData(); ?>
|
31 |
+
|
32 |
_paq.push(['trackPageView']);
|
33 |
|
34 |
<?php echo $this->_getOrderEventsData(); ?>
|
35 |
<?php echo $this->_getCheckoutEventsData(); ?>
|
36 |
<?php echo $this->_getCartEventsData(); ?>
|
|
|
37 |
|
38 |
(function() {
|
39 |
var u="<?php echo $helper->getHost(); ?>";
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Oro_Tracking</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
@@ -17,11 +17,12 @@ This extension adds the pre-configured tracking script to your Magento Store. Th
|
|
17 |
- Successful order placement
|
18 |

|
19 |
All these events will be recorded in OroCRM with connection to customer identity, except for guest customers.</description>
|
20 |
-
<notes>
|
|
|
21 |
<authors><author><name>Oro, Inc</name><user>orocrm</user><email>info@orocrm.com</email></author></authors>
|
22 |
-
<date>2015-
|
23 |
-
<time>
|
24 |
-
<contents><target name="magecommunity"><dir name="Oro"><dir name="Tracking"><dir><dir name="Block"><file name="Tracking.php" hash="
|
25 |
<compatible/>
|
26 |
<dependencies><required><php><min>5.2.13</min><max>5.6.0</max></php></required></dependencies>
|
27 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Oro_Tracking</name>
|
4 |
+
<version>0.1.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
17 |
- Successful order placement
|
18 |

|
19 |
All these events will be recorded in OroCRM with connection to customer identity, except for guest customers.</description>
|
20 |
+
<notes> - fixed compatibility with PHP 5.2
|
21 |
+
- renamed configuration section from "OroCRM API" to "OroCRM"</notes>
|
22 |
<authors><author><name>Oro, Inc</name><user>orocrm</user><email>info@orocrm.com</email></author></authors>
|
23 |
+
<date>2015-04-24</date>
|
24 |
+
<time>10:25:51</time>
|
25 |
+
<contents><target name="magecommunity"><dir name="Oro"><dir name="Tracking"><dir><dir name="Block"><file name="Tracking.php" hash="f38515b66f8c0832bdc97ccff7ade03e"/></dir><dir name="Exception"><file name="ProtocolMismatchException.php" hash="f15069a10465d1206735adcb90a781fd"/></dir><dir name="Helper"><file name="Data.php" hash="a6f42bb3097a2a9d59a9354deb6ae81e"/></dir><dir name="Model"><file name="Observer.php" hash="b13643487263286efcf386c054d7aab1"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d63879b47cf8518a1f280b26b7d3796d"/><file name="config.xml" hash="ac561ec1a92186f1e43ab97390d8eba2"/><file name="system.xml" hash="de0d1efde3f2e5c1b333387b84bdd7bb"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Oro_Tracking.xml" hash="e3db63e3431c4b13bfe485fea9fe1649"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="orotracking.xml" hash="e9a65be3aea707e379b4dd05b188bfe2"/></dir><dir name="template"><dir name="orotracking"><file name="tracking.phtml" hash="6137b5938b8c62357e3851402a473f94"/></dir></dir></dir></dir></dir></target></contents>
|
26 |
<compatible/>
|
27 |
<dependencies><required><php><min>5.2.13</min><max>5.6.0</max></php></required></dependencies>
|
28 |
</package>
|