cadence_fbpixel - Version 1.0.0

Version Notes

Tested on 1.9

Download this release

Release Info

Developer Cadence Labs
Extension cadence_fbpixel
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Cadence/Fbpixel/Helper/Data.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Alan Barber <alan@cadence-labs.com>
4
+ */
5
+ class Cadence_Fbpixel_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+ public function isVisitorPixelEnabled()
8
+ {
9
+ return Mage::getStoreConfig("cadence_fbpixel/visitor/enabled");
10
+ }
11
+
12
+ public function isConversionPixelEnabled()
13
+ {
14
+ return Mage::getStoreConfig("cadence_fbpixel/conversion/enabled");
15
+ }
16
+
17
+ public function getVisitorPixelId()
18
+ {
19
+ return Mage::getStoreConfig("cadence_fbpixel/visitor/pixel_id");
20
+ }
21
+
22
+ public function getConversionPixelId()
23
+ {
24
+ return Mage::getStoreConfig("cadence_fbpixel/conversion/pixel_id");
25
+ }
26
+ }
app/code/community/Cadence/Fbpixel/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
+ <cadence_fbpixel>
12
+ <title>Cadence Labs Facebook Tracking Pixels</title>
13
+ <sort_order>990</sort_order>
14
+ </cadence_fbpixel>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/Cadence/Fbpixel/etc/config.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cadence_Fbpixel>
5
+ <version>0.1.0</version>
6
+ </Cadence_Fbpixel>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <cadence_fbpixel>
11
+ <class>Cadence_Fbpixel_Model</class>
12
+ <resourceModel>cadence_fbpixel_resource</resourceModel>
13
+ </cadence_fbpixel>
14
+ <cadence_fbpixel_resource>
15
+ <class>Cadence_Fbpixel_Model_Resource</class>
16
+ </cadence_fbpixel_resource>
17
+ </models>
18
+ <blocks>
19
+ <cadence_fbpixel>
20
+ <class>Cadence_Fbpixel_Block</class>
21
+ </cadence_fbpixel>
22
+ </blocks>
23
+ <helpers>
24
+ <cadence_fbpixel>
25
+ <class>Cadence_Fbpixel_Helper</class>
26
+ </cadence_fbpixel>
27
+ </helpers>
28
+ </global>
29
+ <frontend>
30
+ <layout>
31
+ <updates>
32
+ <cadence_fbpixel>
33
+ <file>cadence_fbpixel.xml</file>
34
+ </cadence_fbpixel>
35
+ </updates>
36
+ </layout>
37
+ </frontend>
38
+ <default>
39
+ <cadence_fbpixel>
40
+ <visitor>
41
+ <enabled>0</enabled>
42
+ </visitor>
43
+ <conversion>
44
+ <enabled>0</enabled>
45
+ </conversion>
46
+ </cadence_fbpixel>
47
+ </default>
48
+ </config>
app/code/community/Cadence/Fbpixel/etc/system.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <cadence>
5
+ <label>Cadence Labs</label>
6
+ <sort_order>200</sort_order>
7
+ </cadence>
8
+ </tabs>
9
+ <sections>
10
+ <cadence_fbpixel translate="label">
11
+ <label>Facebook Pixels</label>
12
+ <tab>cadence</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>100</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
+ <visitor translate="label">
20
+ <label>Visitor Pixel</label>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <sort_order>1</sort_order>
25
+ <fields>
26
+ <enabled translate="label" module="cadence_fbpixel">
27
+ <label>Enable</label>
28
+ <frontend_type>select</frontend_type>
29
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
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
+ </enabled>
35
+ <pixel_id translate="label">
36
+ <label>Visitor Pixel ID</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>20</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ <comment>This is the pixelId for the visitor tracking pixel (see the install guide for instructions on where to find this).</comment>
43
+ </pixel_id>
44
+ </fields>
45
+ </visitor>
46
+ <conversion translate="label">
47
+ <label>Conversion Pixel</label>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <sort_order>2</sort_order>
52
+ <fields>
53
+ <enabled translate="label" module="cadence_fbpixel">
54
+ <label>Enable</label>
55
+ <frontend_type>select</frontend_type>
56
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
57
+ <sort_order>10</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ </enabled>
62
+ <pixel_id translate="label">
63
+ <label>Conversion Pixel ID</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>20</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ <comment>This is the pixelId for the conversion tracking pixel (see the install guide for instructions on where to find this).</comment>
70
+ </pixel_id>
71
+ </fields>
72
+ </conversion>
73
+ </groups>
74
+ </cadence_fbpixel>
75
+ </sections>
76
+ </config>
app/design/frontend/base/default/layout/cadence_fbpixel.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="after_body_start">
5
+ <block type="core/template" template="cadence/fbpixel/visitor.phtml" />
6
+ </reference>
7
+ </default>
8
+ <checkout_onepage_success translate="label">
9
+ <reference name="after_body_start">
10
+ <block type="core/template" template="cadence/fbpixel/conversion.phtml" />
11
+ </reference>
12
+ </checkout_onepage_success>
13
+ <checkout_multishipping_success translate="label">
14
+ <reference name="after_body_start">
15
+ <block type="core/template" template="cadence/fbpixel/conversion.phtml" />
16
+ </reference>
17
+ </checkout_multishipping_success>
18
+ </layout>
app/design/frontend/base/default/template/cadence/fbpixel/conversion.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $helper = Mage::helper("cadence_fbpixel");
3
+ if (!$helper->isConversionPixelEnabled()) {
4
+ return;
5
+ }
6
+ $id = $helper->getConversionPixelId();
7
+ ?>
8
+ <?php
9
+ $order_id = Mage::getSingleton('checkout/session')->getLastOrderId();
10
+ if (!$order_id || intval($order_id) < 1) {
11
+ //Failsafe for bad order id
12
+ return;
13
+ }
14
+ /** @var Mage_Sales_Model_Order $order */
15
+ $order = Mage::getModel('sales/order')->load($order_id);
16
+ $grand_total = round($order->getGrandTotal(), 2);
17
+ $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
18
+ ?>
19
+ <!-- Facebook Conversion Code for Conversions -->
20
+ <script>(function() {
21
+ var _fbq = window._fbq || (window._fbq = []);
22
+ if (!_fbq.loaded) {
23
+ var fbds = document.createElement('script');
24
+ fbds.async = true;
25
+ fbds.src = '//connect.facebook.net/en_US/fbds.js';
26
+ var s = document.getElementsByTagName('script')[0];
27
+ s.parentNode.insertBefore(fbds, s);
28
+ _fbq.loaded = true;
29
+ }
30
+ })();
31
+ window._fbq = window._fbq || [];
32
+ window._fbq.push(['track', '<?php echo $id ?>', {'value':'<?php echo $grand_total ?>','currency':'<?php echo $currency_code ?>'}]);
33
+ </script>
34
+ <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=<?php echo $id ?>&amp;cd[value]=<?php echo $grand_total ?>&amp;cd[currency]=<?php echo $currency_code ?>&amp;noscript=1" /></noscript>
app/design/frontend/base/default/template/cadence/fbpixel/visitor.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $helper = Mage::helper("cadence_fbpixel");
3
+ if (!$helper->isVisitorPixelEnabled()) {
4
+ return;
5
+ }
6
+ $id = $helper->getVisitorPixelId();
7
+ ?>
8
+ <!-- Facebook Tracking Pixel for Visitors -->
9
+ <script>(function() {
10
+ var _fbq = window._fbq || (window._fbq = []);
11
+ if (!_fbq.loaded) {
12
+ var fbds = document.createElement('script');
13
+ fbds.async = true;
14
+ fbds.src = '//connect.facebook.net/en_US/fbds.js';
15
+ var s = document.getElementsByTagName('script')[0];
16
+ s.parentNode.insertBefore(fbds, s);
17
+ _fbq.loaded = true;
18
+ }
19
+ _fbq.push(['addPixelId', '<?php echo $id ?>']);
20
+ })();
21
+ window._fbq = window._fbq || [];
22
+ window._fbq.push(['track', 'PixelInitialized', {}]);
23
+ </script>
24
+ <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=<?php echo $id ?>&amp;ev=PixelInitialized" /></noscript>
app/etc/modules/Cadence_Fbpixel.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cadence_Fbpixel>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Cadence_Fbpixel>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>cadence_fbpixel</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension allows you to quickly implement Facebook tracking and conversion code on your Magento store. Supports Visitor Tracking and Conversion (Checkout) Pixels</summary>
10
+ <description>&lt;p&gt;This Facebook Conversion Code extension allows you to quickly implement Facebook tracking pixels for website visits and conversions (purchases) within your Magento store. &lt;a href="http://www.cadence-labs.com/2015/03/free-magento-mail-chimp-popup-extention/" title="User Manual"&gt;&lt;strong&gt;Learn how it works.&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;&#xD;
11
+ &lt;p&gt;You may set pixel ids for:&lt;/p&gt;&#xD;
12
+ &lt;ul&gt;&#xD;
13
+ &lt;li&gt;Facebook Visitor Pixel (code is displayed on every page)&lt;/li&gt;&#xD;
14
+ &lt;li&gt;Facebook Conversion Pixel (code is displayed only upon successful checkout)&lt;/li&gt;&#xD;
15
+ &lt;/ul&gt; &#xD;
16
+ &lt;p&gt;Click here to view the official&#xD;
17
+ &lt;a href="http://www.cadence-labs.com/2015/03/free-magento-mail-chimp-popup-extention/" title="User Manual"&gt;Facebook Tracking &amp;amp; Conversion Code User Guide&lt;/a&gt; with detailed step-by-step instructions. &lt;/p&gt;&#xD;
18
+ &lt;h2&gt;Tracks Currency &amp;amp; Grand Total&lt;/h2&gt;&#xD;
19
+ &lt;p&gt;This extension supports stores with multiple currencies, and tracks both the order grand total &amp;amp; order currency (conversion pixel only).&lt;/p&gt; &#xD;
20
+ &#xD;
21
+ &lt;h2&gt;About The Developer&lt;/h2&gt;&#xD;
22
+ &lt;p&gt;&lt;a href="http://www.cadence-labs.com/" title="Cadence Labs"&gt;Cadence Labs&lt;/a&gt; is a digital marketing, design, and Magento agency based in Boulder, Colorado. Our developers are Magento certified eCommerce geeks!&lt;/p&gt;</description>
23
+ <notes>Tested on 1.9</notes>
24
+ <authors><author><name>Cadence Labs</name><user>cadencelabs</user><email>alan@cadence-labs.com</email></author></authors>
25
+ <date>2015-06-26</date>
26
+ <time>22:07:30</time>
27
+ <contents><target name="magecommunity"><dir name="Cadence"><dir name="Fbpixel"><dir name="Helper"><file name="Data.php" hash="473e99657209bd2e1639640321cf0ae3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="5b6a3e063450264720f766584dbd5055"/><file name="config.xml" hash="6cd8b235fdc17c943bb6efb3dda75e52"/><file name="system.xml" hash="188bfafe1689a7b3963dfa2b32993e8d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cadence_Fbpixel.xml" hash="3a82d06be6deb217df2bf11c543bc068"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cadence_fbpixel.xml" hash="7db4331e1b927e1c117b31f74721c522"/></dir><dir name="template"><dir name="cadence"><dir name="fbpixel"><file name="conversion.phtml" hash="a514bb20e86a29fa5179f4c6760a0f78"/><file name="visitor.phtml" hash="8a508b8f1ef444405d4bbc6ad8c6c9bf"/></dir></dir></dir></dir></dir></dir></target></contents>
28
+ <compatible/>
29
+ <dependencies><required><php><min>5.2.0</min><max>5.6.0</max></php></required></dependencies>
30
+ </package>