IntileryAnalytics - Version 1.0.0

Version Notes

First preview release

Download this release

Release Info

Developer Lewis Theobald
Extension IntileryAnalytics
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Intilery/Analytics/Helper/Data.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Intilery_Analytics_Helper_Data extends Mage_Core_Helper_Abstract {
4
+ public function getSomeData() {
5
+
6
+ }
7
+ }
8
+
9
+ ?>
app/code/local/Intilery/Analytics/Model/Observer.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Intilery_Analytics_Model_Observer {
4
+
5
+ public function logProductView(Varien_Event_Observer $observer) {
6
+
7
+ # Set intilery action
8
+ Mage::getSingleton('core/session')->setData('intileryTagType', 'ProductView');
9
+
10
+ # Get the product
11
+ $product = $observer->getProduct();
12
+
13
+ # Store in the session
14
+ Mage::getSingleton('core/session')->setData('productViewData', array(
15
+ 'id' => $product->getId(),
16
+ 'name' => $product->getName(),
17
+ 'price' => $product->getPrice(),
18
+ 'sku' => $product->getSku(),
19
+ 'image' => $product->getImage(),
20
+ 'description' => $product->getDescription()
21
+ )
22
+ );
23
+
24
+ }
25
+
26
+ public function logSearch(Varien_Event_Observer $observer) {
27
+
28
+ # Set intilery action
29
+ Mage::getSingleton('core/session')->setData('intileryTagType', 'Search');
30
+
31
+ # Get the event
32
+ $event = $observer->getEvent();
33
+ $data = $event->getDataObject();
34
+
35
+ # Log data
36
+ Mage::getSingleton('core/session')->setData('searchQuery', $data->getQueryText());
37
+
38
+ }
39
+
40
+ public function logCustomerLogout(Varien_Event_Observer $observer) {
41
+
42
+ # Set intilery action
43
+ Mage::getSingleton('core/session')->setData('intileryTagType', 'CustomerLogout');
44
+
45
+ }
46
+
47
+ public function logCustomerLogin(Varien_Event_Observer $observer) {
48
+
49
+ # Get customer data
50
+ $customer = $observer->getEvent()->getCustomer();
51
+
52
+ # Invalid customer?
53
+ if(!$customer->getId()) {
54
+ return;
55
+ }
56
+
57
+ # Set intilery action
58
+ Mage::getSingleton('core/session')->setData('intileryTagType', 'CustomerLogin');
59
+
60
+ # Store in the session
61
+ Mage::getSingleton('core/session')->setData('customerLogin', array(
62
+ 'email' => $customer->getEmail()
63
+ )
64
+ );
65
+
66
+ }
67
+
68
+
69
+ public function logCustomerRegister(Varien_Event_Observer $observer) {
70
+
71
+ # Set intilery action
72
+ Mage::getSingleton('core/session')->setData('intileryTagType', 'CustomerRegister');
73
+ Mage::getSingleton('core/session')->setData('intileryCustomerRegister', 'CustomerRegister');
74
+
75
+ # Get customer data
76
+ $customer = $observer->getEvent()->getCustomer();
77
+
78
+ # Invalid customer?
79
+ if(!$customer->getId()) {
80
+ return;
81
+ }
82
+
83
+ # Load up the subscriber if possible
84
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
85
+
86
+ # Change boolean
87
+ if(!$subscriber->getId()) {
88
+ $isNewsletter = false;
89
+ } else {
90
+ $isNewsletter = true;
91
+ }
92
+
93
+ # Store in the session
94
+ Mage::getSingleton('core/session')->setData('intileryCustomerData', array(
95
+ 'email' => $customer->getEmail(),
96
+ 'forename' => $customer->getFirstname(),
97
+ 'surname' => $customer->getLastname(),
98
+ 'name' => $customer->getName(),
99
+ 'id' => $customer->getId(),
100
+ 'subscribe' => $isNewsletter
101
+ )
102
+ );
103
+
104
+ # Log data
105
+ Mage::log(json_encode(Mage::getSingleton('core/session')->getData('intileryCustomerData')));
106
+
107
+ }
108
+
109
+ public function logCartUpdate(Varien_Event_Observer $observer) {
110
+
111
+ # Get product
112
+ $quoteItem = $observer->getItem();
113
+ $quantity = $quoteItem->getQty();
114
+ $product = $quoteItem->getProduct();
115
+
116
+ # Valid product?
117
+ if(!$product->getId()) {
118
+ return;
119
+ }
120
+
121
+ # Store in the session
122
+ Mage::getSingleton('core/session')->setData('productUpdateShoppingCart', array(
123
+ 'id' => $product->getId(),
124
+ 'name' => $product->getName(),
125
+ 'quantity' => $quantity,
126
+ 'price' => $product->getPrice(),
127
+ 'sku' => $product->getSku()
128
+ )
129
+ );
130
+
131
+ # Set intilery action
132
+ Mage::getSingleton('core/session')->setData('intileryTagType', 'UpdateCart');
133
+
134
+ }
135
+
136
+ public function logCartAdd(Varien_Event_Observer $observer) {
137
+
138
+ # Get the product added
139
+ $product = Mage::getModel('catalog/product')->load(
140
+ Mage::app()->getRequest()->getParam('product', 0)
141
+ );
142
+
143
+ # Valid product?
144
+ if(!$product->getId()) {
145
+ return;
146
+ }
147
+
148
+ # Get any categories
149
+ $categories = $product->getCategoryIds();
150
+
151
+ # Store in the session
152
+ Mage::getSingleton('core/session')->setData('productInShoppingCart', array(
153
+ 'id' => $product->getId(),
154
+ 'quantity' => Mage::app()->getRequest()->getParam('qty', 1),
155
+ 'name' => $product->getName(),
156
+ 'price' => $product->getPrice(),
157
+ 'sku' => $product->getSku(),
158
+ 'category_name' => Mage::getModel('catalog/category')->load($categories[0])->getName(),
159
+ )
160
+ );
161
+
162
+ # Set intilery action
163
+ Mage::getSingleton('core/session')->setData('intileryTagType', 'AddCart');
164
+
165
+ }
166
+
167
+ public function logCartRemove(Varien_Event_Observer $observer) {
168
+
169
+ # Get the product
170
+ $product = $observer->getQuoteItem()->getProduct();
171
+
172
+ # Valid product?
173
+ if(!$product->getId()) {
174
+ return;
175
+ }
176
+
177
+ # Store in the session
178
+ Mage::getSingleton('core/session')->setData('productOutShoppingCart', array(
179
+ 'id' => $product->getId(),
180
+ 'name' => $product->getName(),
181
+ 'price' => $product->getPrice(),
182
+ 'sku' => $product->getSku()
183
+ )
184
+ );
185
+
186
+ # Set intilery action
187
+ Mage::getSingleton('core/session')->setData('intileryTagType', 'RemoveCart');
188
+
189
+ }
190
+
191
+ }
192
+
193
+ ?>
app/code/local/Intilery/Analytics/etc/adminhtml.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <!-- <menu>
4
+ <intilery module="analytics_admincontroller" translate="title">
5
+ <title>Intilery Analytics</title>
6
+ <sort_order>100</sort_order>
7
+ <children>
8
+ <index module="analytics_admincontroller" translate="title">
9
+ <title>Tracking Code</title>
10
+ <sort_order>1</sort_order>
11
+ <action>adminhtml/intilery</action>
12
+ </index>
13
+ <list module="analytics_admincontroller" translate="title">
14
+ <title>List Action</title>
15
+ <sort_order>2</sort_order>
16
+ <action>adminhtml/intilery/list</action>
17
+ </list>
18
+ </children>
19
+ </intilery>
20
+ </menu> -->
21
+ <acl>
22
+ <resources>
23
+ <admin>
24
+ <children>
25
+ <system>
26
+ <children>
27
+ <config>
28
+ <children>
29
+ <intilery translate="title" module="analytics">
30
+ <title>Tracking Code Section</title>
31
+ <sort_order>100</sort_order>
32
+ </intilery>
33
+ </children>
34
+ </config>
35
+ </children>
36
+ </system>
37
+ </children>
38
+ </admin>
39
+ </resources>
40
+ </acl>
41
+ </config>
app/code/local/Intilery/Analytics/etc/config.xml ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Intilery_Analytics>
5
+ <version>1.0.0</version>
6
+ </Intilery_Analytics>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <analytics>
12
+ <class>Intilery_Analytics_Model</class>
13
+ </analytics>
14
+ </models>
15
+
16
+ <helpers>
17
+ <analytics>
18
+ <class>Intilery_Analytics_Helper</class>
19
+ </analytics>
20
+ <!-- <analytics_admincontroller>
21
+ <class>Mage_Core_Helper</class>
22
+ </analytics_admincontroller> -->
23
+ </helpers>
24
+
25
+ <events>
26
+ <!-- <catalog_product_save_after>
27
+ <observers>
28
+ <analytics>
29
+ <class>analytics/observer</class>
30
+ <method>logUpdate</method>
31
+ <type>singleton</type>
32
+ </analytics>
33
+ </observers>
34
+ </catalog_product_save_after> -->
35
+
36
+ <checkout_cart_add_product_complete>
37
+ <observers>
38
+ <analytics_cart_add>
39
+ <class>analytics/observer</class>
40
+ <method>logCartAdd</method>
41
+ <type>singleton</type>
42
+ </analytics_cart_add>
43
+ </observers>
44
+ </checkout_cart_add_product_complete>
45
+
46
+ <sales_quote_item_qty_set_after>
47
+ <observers>
48
+ <analytics_cart_update>
49
+ <class>analytics/observer</class>
50
+ <method>logCartUpdate</method>
51
+ <type>singleton</type>
52
+ </analytics_cart_update>
53
+ </observers>
54
+ </sales_quote_item_qty_set_after>
55
+
56
+ <!--
57
+ <checkout_cart_update_item_complete>
58
+ <observers>
59
+ <analytics_cart_update>
60
+ <class>analytics/observer</class>
61
+ <method>logCartUpdate</method>
62
+ <type>singleton</type>
63
+ </analytics_cart_update>
64
+ </observers>
65
+ </checkout_cart_update_item_complete>
66
+ -->
67
+
68
+ <sales_quote_remove_item>
69
+ <observers>
70
+ <analytics_cart_remove>
71
+ <class>analytics/observer</class>
72
+ <method>logCartRemove</method>
73
+ <type>singleton</type>
74
+ </analytics_cart_remove>
75
+ </observers>
76
+ </sales_quote_remove_item>
77
+
78
+ <customer_logout>
79
+ <observers>
80
+ <analytics_logout>
81
+ <class>analytics/observer</class>
82
+ <method>logCustomerLogout</method>
83
+ <type>singleton</type>
84
+ </analytics_logout>
85
+ </observers>
86
+ </customer_logout>
87
+
88
+ <customer_login>
89
+ <observers>
90
+ <analytics_login>
91
+ <class>analytics/observer</class>
92
+ <method>logCustomerLogin</method>
93
+ <type>singleton</type>
94
+ </analytics_login>
95
+ </observers>
96
+ </customer_login>
97
+
98
+ <customer_register_success>
99
+ <observers>
100
+ <analytics_register>
101
+ <class>analytics/observer</class>
102
+ <method>logCustomerRegister</method>
103
+ <type>singleton</type>
104
+ </analytics_register>
105
+ </observers>
106
+ </customer_register_success>
107
+
108
+ <catalogsearch_query_load_after>
109
+ <observers>
110
+ <analytics_search>
111
+ <class>analytics/observer</class>
112
+ <method>logSearch</method>
113
+ <type>singleton</type>
114
+ </analytics_search>
115
+ </observers>
116
+ </catalogsearch_query_load_after>
117
+
118
+ <catalog_controller_product_view>
119
+ <observers>
120
+ <analytics_product>
121
+ <class>analytics/observer</class>
122
+ <method>logProductView</method>
123
+ <type>singleton</type>
124
+ </analytics_product>
125
+ </observers>
126
+ </catalog_controller_product_view>
127
+ </events>
128
+ </global>
129
+
130
+ <!-- <admin>
131
+ <routers>
132
+ <analytics>
133
+ <use>admin</use>
134
+ <args>
135
+ <module>Intilery_Analytics</module>
136
+ <frontName>intilery</frontName>
137
+ </args>
138
+ </analytics>
139
+ </routers>
140
+ </admin>
141
+
142
+ <acl>
143
+ <resources>
144
+ <all>
145
+ <title>Allow Everything</title>
146
+ </all>
147
+ <admin>
148
+ <children>
149
+ <analytics translate="title" module="analytics">
150
+ <title>Analytics</title>
151
+ <sort_order>1000</sort_order>
152
+ <children>
153
+ <index translate="title">
154
+ <title>Intilery Analytics</title>
155
+ </index>
156
+ </children>
157
+ </analytics>
158
+ </children>
159
+ </admin>
160
+ </resources>
161
+ </acl>
162
+
163
+ <admin>
164
+ <routers>
165
+ <adminhtml>
166
+ <args>
167
+ <modules>
168
+ <analytics before="Mage_Adminhtml">Intilery_Analytics_Adminhtml</analytics>
169
+ </modules>
170
+ </args>
171
+ </adminhtml>
172
+ </routers>
173
+ </admin> -->
174
+
175
+ <frontend>
176
+ <layout>
177
+ <updates>
178
+ <analytics>
179
+ <file>intileryanalytics.xml</file>
180
+ </analytics>
181
+ </updates>
182
+ </layout>
183
+ </frontend>
184
+
185
+ <default>
186
+ <intilery>
187
+ <tracking>
188
+ <code></code>
189
+ <active>0</active>
190
+ </tracking>
191
+ </intilery>
192
+ </default>
193
+ </config>
app/code/local/Intilery/Analytics/etc/system.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <intilery translate="label" module="analytics">
5
+ <label>Intilery Analytics</label>
6
+ <sort_order>100</sort_order>
7
+ </intilery>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <intilery translate="label" module="analytics">
12
+ <label>Tracking Code</label>
13
+ <tab>intilery</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>100</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+
20
+ <groups>
21
+ <tracking translate="label" module="analytics">
22
+ <label>Tracking Code</label>
23
+ <frontend_type>text</frontend_type>
24
+ <expanded>1</expanded>
25
+ <sort_order>1000</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <fields>
30
+ <code translate="label">
31
+ <label>Account Code:</label>
32
+ <comment>Please enter your account code, you can find this under your settings.</comment>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>20</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </code>
39
+
40
+ <!-- New fields go here -->
41
+ <active translate="label comment">
42
+ <label>Enabled:</label>
43
+ <comment>Select whether or not Intilery tracking is enabled.</comment>
44
+ <frontend_type>select</frontend_type>
45
+ <source_model>adminhtml/system_config_source_yesno</source_model>
46
+ <sort_order>10</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ </active>
51
+ </fields>
52
+ </tracking>
53
+ </groups>
54
+ </intilery>
55
+ </sections>
56
+ </config>
app/design/frontend/base/default/layout/intileryanalytics.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="footer">
5
+ <block type="core/template" name="Intilery_Analytics_footer" template="intilery/footer.phtml" />
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/intilery/footer.phtml ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ # Get our config
4
+ $intileryConfig = Mage::getStoreConfig('intilery/tracking');
5
+
6
+ # Enabled tracking?
7
+ if($intileryConfig['active']) {
8
+
9
+ # Main tracking tag
10
+ echo '
11
+ <script type="text/javascript">
12
+ _gaq = [] || _gaq;window.INTILERY = {};INTILERY.gaq = [];
13
+ (function($, _push) {_gaqPush = _push;$.push = function() {INTILERY.gaq.push(arguments[0]);return _gaqPush.apply(_gaq,arguments);}})(_gaq, _gaq.push);var _itq = _itq || [];
14
+ _itq.push(["_setAccount", "'.$intileryConfig['code'].'"]);
15
+ (function(){
16
+ var it = document.createElement("script"); it.type = "text/javascript"; it.async = true;
17
+ it.src = ("https:" == document.location.protocol ? "https://" : "http://") + "www.intilery-analytics.com/rest/it.js";
18
+ var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(it, s);
19
+ })();
20
+ </script>';
21
+
22
+ # Get any triggered events
23
+ $intileryTagType = Mage::getSingleton('core/session')->getData('intileryTagType', true);
24
+
25
+ # Special cases
26
+ $intileryTagTypeRegister = Mage::getSingleton('core/session')->getData('intileryCustomerRegister', true);
27
+
28
+ # Found register?
29
+ if(!is_null($intileryTagTypeRegister) || ($intileryTagType == 'customerRegister')) {
30
+
31
+ # Any "add to cart" data
32
+ $customerRegisterData = Mage::getSingleton('core/session')->getData('intileryCustomerData', true);
33
+
34
+ if(!is_null($customerRegisterData) && !empty($customerRegisterData)) {
35
+
36
+ echo "<script>
37
+ var _itq = _itq || [];
38
+ _itq.push(['_trackUserEvent','register account',
39
+ [
40
+ {name:'Customer.Email', value:'{$customerRegisterData['email']}'},
41
+ {name:'Customer.First Name', value:'{$customerRegisterData['forename']}'},
42
+ {name:'Customer.Last Name', value:'{$customerRegisterData['surname']}'},
43
+ {name:'Customer.Subscribed', value:'{$customerRegisterData['subscribe']}'}
44
+ ]]);
45
+ </script>";
46
+
47
+ }
48
+
49
+ }
50
+
51
+ # Found some tag type
52
+ if(!is_null($intileryTagType)) {
53
+
54
+ # Login customer
55
+ if($intileryTagType == 'CustomerLogin') {
56
+
57
+ # Any "add to cart" data
58
+ $customerLoginData = Mage::getSingleton('core/session')->getData('customerLogin', true);
59
+
60
+ # Did we add to cart?
61
+ if(!is_null($customerLoginData) && !empty($customerLoginData)) {
62
+
63
+ echo "<script>
64
+ var _itq = _itq || [];
65
+ _itq.push(['_trackUserEvent', 'sign in', [{name:'Customer.Email', value:'{$customerLoginData['email']}'}]]);
66
+ </script>";
67
+
68
+ }
69
+
70
+ # Logout customer
71
+ } elseif($intileryTagType == 'CustomerLogout') {
72
+
73
+ echo "<script>
74
+ var _itq = _itq || [];
75
+ _itq.push(['_trackUserEvent', 'sign out', []]);
76
+ </script>";
77
+
78
+ # When we added to cart
79
+ } elseif($intileryTagType == 'AddCart') {
80
+
81
+ # Any "add to cart" data
82
+ $productAddedToCart = Mage::getSingleton('core/session')->getData('productInShoppingCart', true);
83
+
84
+ # Did we add to cart?
85
+ if(!is_null($productAddedToCart) && !empty($productAddedToCart)) {
86
+
87
+ echo "<script>
88
+ var _itq = _itq || [];
89
+ _itq.push(['_trackUserEvent', 'add to basket', [
90
+     {name:'Add To Basket.SKU', value:'{$productAddedToCart['sku']}'},
91
+     {name:'Add To Basket.Quantity', value:'{$productAddedToCart['quantity']}'},
92
+     {name:'Add To Basket.Price', value:'{$productAddedToCart['price']}'},
93
+     {name:'Product.Name', value:'{$productAddedToCart['name']}'}
94
+ ], 'Add To Basket']);
95
+ </script>";
96
+
97
+ }
98
+
99
+ } elseif($intileryTagType == 'RemoveCart') {
100
+
101
+ # Any "add to cart" data
102
+ $productRemovedFromCart = Mage::getSingleton('core/session')->getData('productOutShoppingCart', true);
103
+
104
+ # Did we add to cart?
105
+ if(!is_null($productRemovedFromCart) && !empty($productRemovedFromCart)) {
106
+
107
+ echo "<script>
108
+ var _itq = _itq || [];
109
+ _itq.push(['_trackUserEvent', 'remove from basket', [
110
+     {name:'Product.Name',value:'{$productRemovedFromCart['name']}'}
111
+ ], 'Remove From Basket']);
112
+ </script>";
113
+
114
+ }
115
+
116
+ } elseif($intileryTagType == 'UpdateCart') {
117
+
118
+ # Any "update sale item cart" data
119
+ $productUpdatedInCart = Mage::getSingleton('core/session')->getData('productUpdateShoppingCart', true);
120
+
121
+ # Did we add to cart?
122
+ if(!is_null($productUpdatedInCart) && !empty($productUpdatedInCart)) {
123
+
124
+ echo "<script>
125
+ var _itq = _itq || [];
126
+ _itq.push(['_trackUserEvent', 'update basket', [
127
+     {name:'Update Basket.Quantity', value:'{$productUpdatedInCart['quantity']}'},
128
+     {name:'Update Basket.Price', value:'{$productUpdatedInCart['price']}'},
129
+     {name:'Product.Name', value:'{$productUpdatedInCart['name']}'}
130
+ ], 'Update Basket']);
131
+ </script>";
132
+
133
+ }
134
+
135
+ } elseif($intileryTagType == 'Search') {
136
+
137
+ # Any "update sale item cart" data
138
+ $searchQueryText = Mage::getSingleton('core/session')->getData('searchQuery', true);
139
+
140
+ # Did we add to cart?
141
+ if(!is_null($searchQueryText) && !empty($searchQueryText)) {
142
+
143
+ echo "<script>
144
+ var _itq = _itq || [];
145
+ _itq.push(['_trackUserEvent', 'Search', [{name:'Search.Term',value:'{$searchQueryText}'}]]);
146
+ </script>";
147
+
148
+ }
149
+
150
+ } elseif($intileryTagType == 'ProductView') {
151
+
152
+ # Get the product data
153
+ $productViewData= Mage::getSingleton('core/session')->getData('productViewData', true);
154
+
155
+ # Did we add to cart?
156
+ if(!is_null($productViewData) && !empty($productViewData)) {
157
+
158
+ echo "<script>
159
+ var _itq = _itq || [];
160
+ _itq.push(['_trackUserEvent', 'view product', [
161
+ {name:'Product.Name', value: '{$productViewData['name']}'},
162
+ {name:'Product.Price', value: '{$productViewData['price']}'},
163
+ {name:'Product.Description', value: '{$productViewData['description']}'},
164
+ {name:'Product.Image', value: '{$productViewData['image']}'}
165
+ ]]);
166
+ </script>";
167
+
168
+ }
169
+
170
+ }
171
+
172
+ }
173
+
174
+ }
175
+
176
+ ?>
app/etc/modules/Intilery_Analytics.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Intilery_Analytics>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Intilery_Analytics>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>IntileryAnalytics</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Install Intilery analytics on your Magento copy</summary>
10
+ <description>Allows the user to connect their Magento installation with their Intilery tracking dashboard.</description>
11
+ <notes>First preview release</notes>
12
+ <authors><author><name>Lewis Theobald</name><user>LewisTheobald</user><email>lewis@aljtmedia.com</email></author></authors>
13
+ <date>2014-01-15</date>
14
+ <time>13:08:21</time>
15
+ <contents><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="intilery"><file name="footer.phtml" hash="478bc3a2bb21359c65bf4a796f651eff"/></dir></dir><dir name="layout"><file name="intileryanalytics.xml" hash="029805cde7e0a232ae1c34ca9c9294dc"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="Intilery"><dir name="Analytics"><dir name="Helper"><file name="Data.php" hash="73eea83351ad9a89cdf5f5ad14054a81"/></dir><dir name="Model"><file name="Observer.php" hash="0cf54fa32cad78ca36f8b9a3571741c9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="02d8db0ec3a9f95fb0f0a8b80c56764a"/><file name="config.xml" hash="2e694f64f95ce0e87843aeafca8abb8e"/><file name="system.xml" hash="073880c6cbfc851b4c7f32c5a60c03cc"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intilery_Analytics.xml" hash="943756b51b7a8bab8175c9132a7473c8"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>