Jaljale_Pixel_Setting - Version 1.0.0

Version Notes

Initial release for facebook pixel setting and conversion tracking.

Download this release

Release Info

Developer Krish
Extension Jaljale_Pixel_Setting
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Jaljale/Pixel/Block/Index.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Jaljale_Pixel_Block_Index extends Mage_Core_Block_Template{
3
+
4
+ public function isAudienceEnable()
5
+ {
6
+ return Mage::helper('pixel')->isAudienceEnable();
7
+ }
8
+
9
+ public function getAudienceCode()
10
+ {
11
+ return Mage::helper('pixel')->getAudienceCode();
12
+ }
13
+
14
+ public function isTrackingEnable()
15
+ {
16
+ return Mage::helper('pixel')->isTrackingEnable();
17
+ }
18
+
19
+ public function getTrackingCode()
20
+ {
21
+ return Mage::helper('pixel')->getTrackingCode();
22
+ }
23
+
24
+ public function getCurrency()
25
+ {
26
+ return Mage::helper('pixel')->getCurrency();
27
+ }
28
+
29
+
30
+ public function getPageName()
31
+ {
32
+ return Mage::helper('pixel')->getPageName();
33
+ }
34
+
35
+ public function getOrderValue()
36
+ {
37
+ //$_customerId = Mage::getSingleton('customer/session')->getCustomerId();
38
+
39
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
40
+ $order = Mage::getSingleton('sales/order');
41
+ $order->load($lastOrderId);
42
+
43
+ return round($order->getGrandTotal(), 2);
44
+ }
45
+
46
+
47
+
48
+ }
app/code/community/Jaljale/Pixel/Helper/Data.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Jaljale_Pixel_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ public static $_store = '';
5
+
6
+ protected function _getStore()
7
+ {
8
+ if(self::$_store){
9
+ self::$_store = Mage::app()->getStore()->getStoreId();
10
+ }
11
+
12
+ return self::$_store;
13
+ }
14
+
15
+ public function isAudienceEnable()
16
+ {
17
+ return Mage::getStoreConfig('pixal/audience/enable', $this->_getStore());
18
+ }
19
+
20
+ public function getAudienceCode()
21
+ {
22
+ return Mage::getStoreConfig('pixal/audience/code', $this->_getStore());
23
+ }
24
+
25
+ public function isTrackingEnable()
26
+ {
27
+ return Mage::getStoreConfig('pixal/tracking/enable', $this->_getStore());
28
+ }
29
+
30
+ public function getTrackingCode()
31
+ {
32
+ return Mage::getStoreConfig('pixal/tracking/code', $this->_getStore());
33
+ }
34
+
35
+ public function getCurrency()
36
+ {
37
+ return Mage::getStoreConfig('pixal/tracking/currency', $this->_getStore());
38
+ }
39
+
40
+
41
+
42
+ public function getPageName()
43
+ {
44
+ //home, category, product, cart, purchase, siteview
45
+ //purchase = success pages
46
+ //Siteview = all other pages not contained in home, category, product, cart, purchase
47
+ //checkout = checkout
48
+
49
+ $module = Mage::app()->getRequest()->getModuleName();
50
+ $controller = Mage::app()->getRequest()->getControllerName();
51
+ $action = Mage::app()->getRequest()->getActionName();
52
+
53
+ if ('cms' == $module && 'index' == $controller && 'index' == $action)
54
+ {
55
+ $pageName = 'home';
56
+ }
57
+ else if ('catalog' == $module && 'product' == $controller && 'view' == $action)
58
+ {
59
+ $pageName = 'product';
60
+ $product = Mage::getModel('catalog/product')->load(
61
+ Mage::app()->getRequest()->getParam('id'));
62
+ $ean = $product->getSku();
63
+ }
64
+ else if ('checkout' == $module && 'onepage' == $controller && 'index' == $action)
65
+ {
66
+ if (!Mage::getSingleton('customer/session')->isLoggedIn())
67
+ {
68
+ $pageName = 'cart';
69
+ } else {
70
+ $pageName = 'checkout';
71
+ }
72
+ }
73
+ else if ('checkout' == $module && 'onepage' == $controller && 'success' == $action)
74
+ {
75
+ $pageName = 'purchase';
76
+ }
77
+ else
78
+ $pageName = 'siteview';
79
+
80
+ return $pageName;
81
+ }
82
+ }
83
+
app/code/community/Jaljale/Pixel/controllers/IndexController.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Jaljale_Pixel_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function IndexAction() {
4
+
5
+ $this->loadLayout();
6
+ $this->getLayout()->getBlock("head")->setTitle($this->__("Pixel"));
7
+ $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
8
+ $breadcrumbs->addCrumb("home", array(
9
+ "label" => $this->__("Home Page"),
10
+ "title" => $this->__("Home Page"),
11
+ "link" => Mage::getBaseUrl()
12
+ ));
13
+
14
+ $breadcrumbs->addCrumb("Pixel", array(
15
+ "label" => $this->__("Pixel"),
16
+ "title" => $this->__("Pixel")
17
+ ));
18
+
19
+ $this->renderLayout();
20
+
21
+ }
22
+ }
app/code/community/Jaljale/Pixel/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <pixal translate="title" module="pixel">
12
+ <title>Pixel Setting Section</title>
13
+ <sort_order>0</sort_order>
14
+ </pixal>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/Jaljale/Pixel/etc/config.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <default>
4
+ <pixal>
5
+ <audience>
6
+ <enable>0</enable>
7
+ <code>000</code>
8
+ </audience>
9
+ <tracking>
10
+ <enable>0</enable>
11
+ <code>000</code>
12
+ <currency>USD</currency>
13
+ </tracking>
14
+ </pixal>
15
+ </default>
16
+ <modules>
17
+ <Jaljale_Pixel>
18
+ <version>0.1.0</version>
19
+ </Jaljale_Pixel>
20
+ </modules>
21
+ <frontend>
22
+ <routers>
23
+ <pixel>
24
+ <use>standard</use>
25
+ <args>
26
+ <module>Jaljale_Pixel</module>
27
+ <frontName>pixel</frontName>
28
+ </args>
29
+ </pixel>
30
+ </routers>
31
+ <layout>
32
+ <updates>
33
+ <pixel>
34
+ <file>pixel.xml</file>
35
+ </pixel>
36
+ </updates>
37
+ </layout>
38
+ </frontend>
39
+ <global>
40
+ <helpers>
41
+ <pixel>
42
+ <class>Jaljale_Pixel_Helper</class>
43
+ </pixel>
44
+ </helpers>
45
+ <blocks>
46
+ <pixel>
47
+ <class>Jaljale_Pixel_Block</class>
48
+ </pixel>
49
+ </blocks>
50
+ </global>
51
+ </config>
app/code/community/Jaljale/Pixel/etc/system.xml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <jaljale translate="label" module="pixel">
5
+ <label>Jaljale</label>
6
+ <sort_order>0</sort_order>
7
+ </jaljale>
8
+ </tabs>
9
+ <sections>
10
+ <pixal translate="label" module="pixel">
11
+ <label>Pixel Setting</label>
12
+ <tab>jaljale</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>101</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
+ <audience translate="label">
20
+ <label>Facebook Audience Pixel</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>0</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <enable translate="label">
28
+ <label>Enable</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </enable>
36
+ <code translate="label">
37
+ <label>Pixel Code</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>1</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
+ <comment>Enter your facebook audience pixel code</comment>
44
+ <depends><enable>1</enable></depends>
45
+ </code>
46
+
47
+ </fields>
48
+ </audience>
49
+ <tracking translate="label">
50
+ <label>Conversion-Tracking Pixel </label>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>1</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ <fields>
57
+ <enable translate="label">
58
+ <label>Enable</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>0</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </enable>
66
+ <code translate="label">
67
+ <label>Pixel Code</label>
68
+ <frontend_type>text</frontend_type>
69
+ <sort_order>1</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ <comment>Enter your facebook conversion-tracking pixel code</comment>
74
+ <depends><enable>1</enable></depends>
75
+ </code>
76
+ <currency translate="label">
77
+ <label>Currency</label>
78
+ <frontend_type>select</frontend_type>
79
+ <source_model>adminhtml/system_config_source_currency</source_model>
80
+ <sort_order>2</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ <comment>Choose currency</comment>
85
+ <depends><enable>1</enable></depends>
86
+ </currency>
87
+
88
+
89
+ </fields>
90
+ </tracking>
91
+ </groups>
92
+ </pixal>
93
+ </sections>
94
+ </config>
app/design/frontend/base/default/layout/pixel.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="root">
5
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
6
+ </reference>
7
+ <reference name="head">
8
+ <block type="pixel/index" name="pixel_index" template="pixel/index.phtml"/>
9
+ </reference>
10
+ </default>
11
+ </layout>
12
+
app/design/frontend/base/default/template/pixel/index.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ <?php
4
+ if($this->isAudienceEnable()):
5
+ if($this->getAudienceCode()):
6
+ ?>
7
+ <script>(function() {
8
+ var _fbq = window._fbq || (window._fbq = []);
9
+ if (!_fbq.loaded) {
10
+ var fbds = document.createElement('script');
11
+ fbds.async = true;
12
+ fbds.src = '//connect.facebook.net/en_US/fbds.js';
13
+ var s = document.getElementsByTagName('script')[0];
14
+ s.parentNode.insertBefore(fbds, s);
15
+ _fbq.loaded = true;
16
+ }
17
+ _fbq.push(['addPixelId', '<?php echo $this->getAudienceCode(); ?>']);
18
+ })();
19
+ window._fbq = window._fbq || [];
20
+ window._fbq.push(['track', 'PixelInitialized', {}]);
21
+ </script>
22
+ <noscript>
23
+ <img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=<?php echo $this->getAudienceCode(); ?>&amp;ev=PixelInitialized" />
24
+ </noscript>
25
+ <?php
26
+ endif;
27
+ endif;
28
+ ?>
29
+
30
+ <?php
31
+ if($this->getPageName() == 'purchase'):
32
+ if($this->isTrackingEnable()):
33
+ if($this->getTrackingCode()):
34
+ ?>
35
+ <!-- Facebook Conversion Code for Test -->
36
+ <script>
37
+ (function() {
38
+ var _fbq = window._fbq || (window._fbq = []);
39
+ if (!_fbq.loaded) {
40
+ var fbds = document.createElement('script');
41
+ fbds.async = true;
42
+ fbds.src = '//connect.facebook.net/en_US/fbds.js';
43
+ var s = document.getElementsByTagName('script')[0];
44
+ s.parentNode.insertBefore(fbds, s);
45
+ _fbq.loaded = true;
46
+ }
47
+ })();
48
+ window._fbq = window._fbq || [];
49
+ window._fbq.push(['track', '<?php echo $this->getTrackingCode(); ?>', {'value':'<?php echo $this->getOrderValue(); ?>','currency':'<?php echo $this->getCurrency();?>'}]);
50
+ </script>
51
+ <noscript>
52
+ <img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=<?php echo $this->getTrackingCode();; ?>&amp;cd[value]=<?php echo $this->getOrderValue(); ?>&amp;cd[currency]=<?php echo $this->getCurrency();?>&amp;noscript=1" />
53
+ </noscript>
54
+ <?php
55
+ endif;
56
+ endif;
57
+ endif;
58
+ ?>
59
+
60
+
61
+
app/etc/modules/Jaljale_Pixel.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <modules>
4
+ <Jaljale_Pixel>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>0.1.0</version>
8
+ </Jaljale_Pixel>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Jaljale_Pixel_Setting</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-3.0.en.html">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Magento module for Facebook Conversion Tracking and Custom Audience Re-targeting for Facebook </summary>
10
+ <description>Magento module for Facebook Conversion Tracking and Custom Audience Re-targeting for Facebook &#xD;
11
+ &#xD;
12
+ &#x201C;Facebook Audience Pixel&#x201D; gives you the ability for superior advertising targeting audience of people who have visited your website (while logged in to Facebook).&#xD;
13
+ &#xD;
14
+ &#x201C;Conversion-Tracking Pixel&#x201D; is an amazing conversion measurement tool launched by facebook, Facebook advertisers can access to their ROI (Return of Investment) by keeping a track over user actions.&#xD;
15
+ &#xD;
16
+ This module helps businesses, measure the performance of their Facebook Ads by reporting on the actions people take after viewing those ads.&#xD;
17
+ &#xD;
18
+ Advertisers can create pixels that track conversions, add them to the pages of their website where the conversions will happen, and then track these conversions back to ads they are running on Facebook.&#xD;
19
+ </description>
20
+ <notes>Initial release for facebook pixel setting and conversion tracking.</notes>
21
+ <authors><author><name>Krish</name><user>jaljale</user><email>jaljaletech@gmail.com</email></author><author><name>Subin Shrestha</name><user>sthasbin</user><email>sthasbin@jaljale.com</email></author></authors>
22
+ <date>2015-06-17</date>
23
+ <time>09:41:35</time>
24
+ <contents><target name="magecommunity"><dir name="Jaljale"><dir name="Pixel"><dir name="Block"><file name="Index.php" hash="133c09a8d380f089fbd4bef292c51578"/></dir><dir name="Helper"><file name="Data.php" hash="4e07e3897562838a721075079cecd855"/></dir><dir name="controllers"><file name="IndexController.php" hash="746d0e3172aa6c04e304dc0d912b2596"/></dir><dir name="etc"><file name="adminhtml.xml" hash="725829fdcedd69142d6fad0efa36ec3e"/><file name="config.xml" hash="482be426959e462eb5c95a0db767ae84"/><file name="system.xml" hash="2253a01a4ebfa62b52bb1e250956a0f3"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pixel.xml" hash="6dcc42d26ad17cde4ee38bfc5974db75"/></dir><dir name="template"><dir name="pixel"><file name="index.phtml" hash="65366783fcc9f9e62d53156f1826e53c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Jaljale_Pixel.xml" hash="b32d7c4d8db1e19d09dbe4cda739cd59"/></dir></target></contents>
25
+ <compatible/>
26
+ <dependencies><required><php><min>5.1.3</min><max>6.5.5</max></php></required></dependencies>
27
+ </package>