Apptrian_Facebook_Pixel - Version 1.0.0

Version Notes

Initial release.

Download this release

Release Info

Developer Apptrian
Extension Apptrian_Facebook_Pixel
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Apptrian/FacebookPixel/Block/Adminhtml/About.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Apptrian
4
+ * @package Apptrian_FacebookPixel
5
+ * @author Apptrian
6
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
+ */
9
+ class Apptrian_FacebookPixel_Block_Adminhtml_About
10
+ extends Mage_Adminhtml_Block_Abstract
11
+ implements Varien_Data_Form_Element_Renderer_Interface
12
+ {
13
+
14
+ /**
15
+ * Render fieldset html
16
+ *
17
+ * @param Varien_Data_Form_Element_Abstract $element
18
+ * @return string
19
+ */
20
+ public function render(Varien_Data_Form_Element_Abstract $element)
21
+ {
22
+ $element = null;
23
+ $version = Mage::helper('apptrian_facebookpixel')
24
+ ->getExtensionVersion();
25
+ $logopath = 'http://www.apptrian.com/media/apptrian.gif';
26
+ $html = <<<HTML
27
+ <div style="background:url('$logopath') no-repeat scroll 15px 15px #e7efef;
28
+ border:1px solid #ccc; min-height:100px; margin:5px 0;
29
+ padding:15px 15px 15px 140px;">
30
+ <p>
31
+ <strong>Apptrian Facebook Pixel Extension v$version</strong><br />
32
+ Adds Facebook Pixel with standard events on appropriate pages. Passes W3C
33
+ validation. Easy to install and use.
34
+ </p>
35
+ <p>
36
+ Website:
37
+ <a href="http://www.apptrian.com" target="_blank">www.apptrian.com</a><br />
38
+ Like, share and follow us on
39
+ <a href="https://www.facebook.com/apptrian" target="_blank">Facebook</a>,
40
+ <a href="https://plus.google.com/+ApptrianCom" target="_blank">Google+</a>,
41
+ <a href="http://www.pinterest.com/apptrian" target="_blank">Pinterest</a>, and
42
+ <a href="http://twitter.com/apptrian" target="_blank">Twitter</a>.<br />
43
+ If you have any questions send email at
44
+ <a href="mailto:service@apptrian.com">service@apptrian.com</a>.
45
+ </p>
46
+ </div>
47
+ HTML;
48
+ return $html;
49
+ }
50
+ }
app/code/community/Apptrian/FacebookPixel/Block/Adminhtml/Info.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Apptrian
4
+ * @package Apptrian_FacebookPixel
5
+ * @author Apptrian
6
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
+ */
9
+ class Apptrian_FacebookPixel_Block_Adminhtml_Info
10
+ extends Mage_Adminhtml_Block_Abstract
11
+ implements Varien_Data_Form_Element_Renderer_Interface
12
+ {
13
+
14
+ /**
15
+ * Render fieldset html
16
+ *
17
+ * @param Varien_Data_Form_Element_Abstract $element
18
+ * @return string
19
+ */
20
+ public function render(Varien_Data_Form_Element_Abstract $element)
21
+ {
22
+ $element = null;
23
+ $logopath = 'http://www.apptrian.com/media/apptrian.gif';
24
+ $html = <<<HTML
25
+ <div style="background:url('$logopath') no-repeat scroll 15px 15px #e7efef;
26
+ border:1px solid #ccc; min-height:100px; margin:5px 0;
27
+ padding:15px 15px 15px 140px;">
28
+ <p>
29
+ <strong>Magento Online Stores &amp; Extensions</strong><br />
30
+ <a href="http://www.apptrian.com" target="_blank">Apptrian</a> offers a wide
31
+ choice of products and services for your online business.
32
+ </p>
33
+ <p>
34
+ Website: <a href="http://www.apptrian.com" target="_blank">www.apptrian.com</a>
35
+ <br />
36
+ Like, share and follow us on
37
+ <a href="https://www.facebook.com/apptrian" target="_blank">Facebook</a>,
38
+ <a href="https://plus.google.com/+ApptrianCom" target="_blank">Google+</a>,
39
+ <a href="http://www.pinterest.com/apptrian" target="_blank">Pinterest</a>, and
40
+ <a href="http://twitter.com/apptrian" target="_blank">Twitter</a>.<br />
41
+ If you have any questions send email at
42
+ <a href="mailto:service@apptrian.com">service@apptrian.com</a>.
43
+ </p>
44
+ </div>
45
+ <div>
46
+ <p><strong>Products and services you might be interested in:</strong></p>
47
+ <a href="http://www.apptrian.com/image-optimizer-for-magento"
48
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
49
+ <img src="http://www.apptrian.com/media/image-optimizer.jpg"
50
+ alt="Image Optimizer" style="border:1px solid #ccc;" />
51
+ </a>
52
+ <a href="http://www.apptrian.com/minify-html-css-js-for-magento"
53
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
54
+ <img src="http://www.apptrian.com/media/minify-html-css-js.jpg"
55
+ alt="Minify HTML CSS JS" style="border:1px solid #ccc;" />
56
+ </a>
57
+ <a href="http://www.apptrian.com/professional-magento-installation"
58
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
59
+ <img src="http://www.apptrian.com/media/professional-magento-installation.jpg"
60
+ alt="Professional Magento Installation" style="border:1px solid #ccc;" />
61
+ </a>
62
+ <a href="http://www.apptrian.com/quick-search-for-magento"
63
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
64
+ <img src="http://www.apptrian.com/media/quick-search.jpg"
65
+ alt="Quick Search" style="border:1px solid #ccc;" />
66
+ </a>
67
+ <a href="http://www.apptrian.com/responsive-product-slider-for-magento"
68
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
69
+ <img src="http://www.apptrian.com/media/responsive-product-slider.jpg"
70
+ alt="Responsive Product Slider" style="border:1px solid #ccc;" />
71
+ </a>
72
+ <a href="http://www.apptrian.com/schema-org-microdata-for-magento"
73
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
74
+ <img src="http://www.apptrian.com/media/schema-org-microdata-for-magento.jpg"
75
+ alt="Schema.org Microdata for Magento" style="border:1px solid #ccc;" />
76
+ </a>
77
+ <a href="http://www.apptrian.com/snippets-generator-for-magento"
78
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
79
+ <img src="http://www.apptrian.com/media/snippets-generator.jpg"
80
+ alt="Snippets Generator" style="border:1px solid #ccc;" />
81
+ </a>
82
+ <a href="http://www.apptrian.com/social-integrator-for-magento"
83
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
84
+ <img src="http://www.apptrian.com/media/social-integrator.jpg"
85
+ alt="Social Integrator" style="border:1px solid #ccc;" />
86
+ </a>
87
+ <a href="http://www.apptrian.com/subcategories-grid-list-for-magento"
88
+ target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
89
+ <img src="http://www.apptrian.com/media/subcategories-grid-list.jpg"
90
+ alt="Subcategories Grid/List" style="border:1px solid #ccc;" />
91
+ </a>
92
+ </div>
93
+ HTML;
94
+ return $html;
95
+ }
96
+ }
app/code/community/Apptrian/FacebookPixel/Block/Code.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Apptrian
4
+ * @package Apptrian_FacebookPixel
5
+ * @author Apptrian
6
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
+ */
9
+ class Apptrian_FacebookPixel_Block_Code extends Mage_Core_Block_Template
10
+ {
11
+
12
+ /**
13
+ * Used in code.phtml and returns needed data.
14
+ *
15
+ * @return array
16
+ */
17
+ public function getFacebookPixelData()
18
+ {
19
+ $data = array();
20
+
21
+ $data['id'] = Mage::getStoreConfig(
22
+ 'apptrian_facebookpixel/general/pixel_id'
23
+ );
24
+
25
+ $data['full_action_name'] = Mage::app()->getFrontController()
26
+ ->getAction()->getFullActionName();
27
+
28
+ return $data;
29
+ }
30
+
31
+ }
app/code/community/Apptrian/FacebookPixel/Helper/Data.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Apptrian
4
+ * @package Apptrian_FacebookPixel
5
+ * @author Apptrian
6
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
+ */
9
+ class Apptrian_FacebookPixel_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+
12
+ /**
13
+ * Returns extension version.
14
+ *
15
+ * @return string
16
+ */
17
+ public function getExtensionVersion()
18
+ {
19
+ return (string) Mage::getConfig()->getNode()
20
+ ->modules->Apptrian_FacebookPixel->version;
21
+ }
22
+
23
+ }
app/code/community/Apptrian/FacebookPixel/Model/Config/Pixelid.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Apptrian
4
+ * @package Apptrian_FacebookPixel
5
+ * @author Apptrian
6
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
+ */
9
+ class Apptrian_FacebookPixel_Model_Config_Pixelid
10
+ extends Mage_Core_Model_Config_Data
11
+ {
12
+
13
+ public function _beforeSave()
14
+ {
15
+
16
+ $result = $this->validate();
17
+
18
+ if ($result !== true) {
19
+
20
+ Mage::throwException(implode("\n", $result));
21
+
22
+ }
23
+
24
+ return parent::_beforeSave();
25
+
26
+ }
27
+
28
+ public function validate()
29
+ {
30
+
31
+ $errors = array();
32
+ $helper = Mage::helper('apptrian_facebookpixel');
33
+ $value = $this->getValue();
34
+ $validator = Zend_Validate::is(
35
+ $value, 'Regex', array('pattern' => '/^[0-9]+$/')
36
+ );
37
+
38
+ if (!$validator) {
39
+ $errors[] = $helper->__('Facebook Pixel ID is not valid.');
40
+ }
41
+
42
+ if (empty($errors)) {
43
+ return true;
44
+ }
45
+
46
+ return $errors;
47
+
48
+ }
49
+
50
+ }
app/code/community/Apptrian/FacebookPixel/etc/config.xml ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Apptrian
5
+ * @package Apptrian_FacebookPixel
6
+ * @author Apptrian
7
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Apptrian_FacebookPixel>
14
+ <version>1.0.0</version>
15
+ </Apptrian_FacebookPixel>
16
+ </modules>
17
+ <global>
18
+ <models>
19
+ <apptrian_facebookpixel>
20
+ <class>Apptrian_FacebookPixel_Model</class>
21
+ </apptrian_facebookpixel>
22
+ </models>
23
+ <resources>
24
+ <apptrian_facebookpixel_setup>
25
+ <setup>
26
+ <module>Apptrian_FacebookPixel</module>
27
+ </setup>
28
+ <connection>
29
+ <use>core_setup</use>
30
+ </connection>
31
+ </apptrian_facebookpixel_setup>
32
+ </resources>
33
+ <blocks>
34
+ <apptrian_facebookpixel>
35
+ <class>Apptrian_FacebookPixel_Block</class>
36
+ </apptrian_facebookpixel>
37
+ </blocks>
38
+ <helpers>
39
+ <apptrian_facebookpixel>
40
+ <class>Apptrian_FacebookPixel_Helper</class>
41
+ </apptrian_facebookpixel>
42
+ </helpers>
43
+ </global>
44
+ <default>
45
+ <apptrian_facebookpixel>
46
+ <general>
47
+ <enabled>1</enabled>
48
+ <pixel_id>123456789012345</pixel_id>
49
+ </general>
50
+ </apptrian_facebookpixel>
51
+ </default>
52
+ <frontend>
53
+ <layout>
54
+ <updates>
55
+ <apptrian_facebookpixel>
56
+ <file>apptrian_facebookpixel.xml</file>
57
+ </apptrian_facebookpixel>
58
+ </updates>
59
+ </layout>
60
+ <translate>
61
+ <modules>
62
+ <Apptrian_FacebookPixel>
63
+ <files>
64
+ <default>Apptrian_FacebookPixel.csv</default>
65
+ </files>
66
+ </Apptrian_FacebookPixel>
67
+ </modules>
68
+ </translate>
69
+ </frontend>
70
+ <adminhtml>
71
+ <acl>
72
+ <resources>
73
+ <admin>
74
+ <children>
75
+ <system>
76
+ <children>
77
+ <config>
78
+ <children>
79
+ <apptrian_info>
80
+ <title>Info</title>
81
+ </apptrian_info>
82
+ <apptrian_facebookpixel>
83
+ <title>Facebook Pixel</title>
84
+ </apptrian_facebookpixel>
85
+ </children>
86
+ </config>
87
+ </children>
88
+ </system>
89
+ </children>
90
+ </admin>
91
+ </resources>
92
+ </acl>
93
+ <translate>
94
+ <modules>
95
+ <Apptrian_FacebookPixel>
96
+ <files>
97
+ <default>Apptrian_FacebookPixel.csv</default>
98
+ </files>
99
+ </Apptrian_FacebookPixel>
100
+ </modules>
101
+ </translate>
102
+ </adminhtml>
103
+ </config>
app/code/community/Apptrian/FacebookPixel/etc/system.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Apptrian
5
+ * @package Apptrian_FacebookPixel
6
+ * @author Apptrian
7
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
9
+ */
10
+ -->
11
+ <config>
12
+ <tabs>
13
+ <apptrian_extensions>
14
+ <label>Apptrian Extensions</label>
15
+ <sort_order>100</sort_order>
16
+ </apptrian_extensions>
17
+ </tabs>
18
+ <sections>
19
+ <apptrian_info translate="label">
20
+ <label>Info</label>
21
+ <tab>apptrian_extensions</tab>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1000000</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <groups>
28
+ <info>
29
+ <frontend_model>apptrian_facebookpixel/adminhtml_info</frontend_model>
30
+ <sort_order>1</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
+ </info>
35
+ </groups>
36
+ </apptrian_info>
37
+ <apptrian_facebookpixel translate="label" >
38
+ <label>Facebook Pixel</label>
39
+ <tab>apptrian_extensions</tab>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>1</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <groups>
46
+ <about translate="label">
47
+ <label>About</label>
48
+ <frontend_type>text</frontend_type>
49
+ <sort_order>1</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ <fields>
54
+ <info translate="label">
55
+ <frontend_model>apptrian_facebookpixel/adminhtml_about</frontend_model>
56
+ <sort_order>1</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </info>
61
+ </fields>
62
+ </about>
63
+ <general translate="label">
64
+ <label>General</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>2</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <fields>
71
+ <enabled translate="label comment">
72
+ <label>Enabled</label>
73
+ <frontend_type>select</frontend_type>
74
+ <source_model>adminhtml/system_config_source_yesno</source_model>
75
+ <sort_order>1</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ <comment>Enables or disables extension.</comment>
80
+ </enabled>
81
+ <pixel_id translate="label comment">
82
+ <label>Facebook Pixel ID</label>
83
+ <frontend_type>text</frontend_type>
84
+ <validate>required-entry</validate>
85
+ <backend_model>apptrian_facebookpixel/config_pixelid</backend_model>
86
+ <sort_order>2</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <comment>Your Facebook Pixel ID.</comment>
91
+ <depends>
92
+ <enabled>1</enabled>
93
+ </depends>
94
+ </pixel_id>
95
+ </fields>
96
+ </general>
97
+ </groups>
98
+ </apptrian_facebookpixel>
99
+ </sections>
100
+ </config>
app/design/frontend/base/default/layout/apptrian_facebookpixel.xml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Apptrian
5
+ * @package Apptrian_FacebookPixel
6
+ * @author Apptrian
7
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
9
+ */
10
+ -->
11
+ <layout version="0.1.0">
12
+ <cms_index_index>
13
+ <reference name="before_body_end">
14
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.home" after="-">
15
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
16
+ <template>apptrian/facebookpixel/code.phtml</template>
17
+ </action>
18
+ </block>
19
+ </reference>
20
+ </cms_index_index>
21
+ <cms_page_view>
22
+ <reference name="before_body_end">
23
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.cms" after="-">
24
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
25
+ <template>apptrian/facebookpixel/code.phtml</template>
26
+ </action>
27
+ </block>
28
+ </reference>
29
+ </cms_page_view>
30
+ <catalog_category_default>
31
+ <reference name="before_body_end">
32
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.category" after="-">
33
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
34
+ <template>apptrian/facebookpixel/code.phtml</template>
35
+ </action>
36
+ </block>
37
+ </reference>
38
+ </catalog_category_default>
39
+ <catalog_category_layered>
40
+ <reference name="before_body_end">
41
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.category" after="-">
42
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
43
+ <template>apptrian/facebookpixel/code.phtml</template>
44
+ </action>
45
+ </block>
46
+ </reference>
47
+ </catalog_category_layered>
48
+ <catalog_product_view>
49
+ <reference name="before_body_end">
50
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.product" after="-">
51
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
52
+ <template>apptrian/facebookpixel/code.phtml</template>
53
+ </action>
54
+ </block>
55
+ </reference>
56
+ </catalog_product_view>
57
+ <catalogsearch_result_index>
58
+ <reference name="before_body_end">
59
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.search" after="-">
60
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
61
+ <template>apptrian/facebookpixel/code.phtml</template>
62
+ </action>
63
+ </block>
64
+ </reference>
65
+ </catalogsearch_result_index>
66
+ <catalogsearch_advanced_result>
67
+ <reference name="before_body_end">
68
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.search" after="-">
69
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
70
+ <template>apptrian/facebookpixel/code.phtml</template>
71
+ </action>
72
+ </block>
73
+ </reference>
74
+ </catalogsearch_advanced_result>
75
+ <customer_account_create>
76
+ <reference name="before_body_end">
77
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.registration" after="-">
78
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
79
+ <template>apptrian/facebookpixel/code.phtml</template>
80
+ </action>
81
+ </block>
82
+ </reference>
83
+ </customer_account_create>
84
+ <checkout_cart_index>
85
+ <reference name="before_body_end">
86
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.cart" after="-">
87
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
88
+ <template>apptrian/facebookpixel/code.phtml</template>
89
+ </action>
90
+ </block>
91
+ </reference>
92
+ </checkout_cart_index>
93
+ <checkout_onepage_index>
94
+ <reference name="before_body_end">
95
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.checkout" after="-">
96
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
97
+ <template>apptrian/facebookpixel/code.phtml</template>
98
+ </action>
99
+ </block>
100
+ </reference>
101
+ </checkout_onepage_index>
102
+ <onestepcheckout_index_index>
103
+ <reference name="before_body_end">
104
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.checkout" after="-">
105
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
106
+ <template>apptrian/facebookpixel/code.phtml</template>
107
+ </action>
108
+ </block>
109
+ </reference>
110
+ </onestepcheckout_index_index>
111
+ <opc_index_index>
112
+ <reference name="before_body_end">
113
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.checkout" after="-">
114
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
115
+ <template>apptrian/facebookpixel/code.phtml</template>
116
+ </action>
117
+ </block>
118
+ </reference>
119
+ </opc_index_index>
120
+ <checkout_onepage_success>
121
+ <reference name="before_body_end">
122
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.purchase" after="-">
123
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
124
+ <template>apptrian/facebookpixel/code.phtml</template>
125
+ </action>
126
+ </block>
127
+ </reference>
128
+ </checkout_onepage_success>
129
+ <wishlist_index_index>
130
+ <reference name="before_body_end">
131
+ <block type="apptrian_facebookpixel/code" name="apptrian.facebookpixel.wishlist" after="-">
132
+ <action method="setTemplate" ifconfig="apptrian_facebookpixel/general/enabled">
133
+ <template>apptrian/facebookpixel/code.phtml</template>
134
+ </action>
135
+ </block>
136
+ </reference>
137
+ </wishlist_index_index>
138
+ </layout>
app/design/frontend/base/default/template/apptrian/facebookpixel/code.phtml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Apptrian
4
+ * @package Apptrian_FacebookPixel
5
+ * @author Apptrian
6
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
+ */
9
+
10
+ // @codingStandardsIgnoreFile
11
+
12
+ ?>
13
+ <?php
14
+ /**
15
+ * Facebook Pixel Code block
16
+ *
17
+ * @var $block Apptrian_FacebookPixel_Block_Code
18
+ */
19
+
20
+ $data = $this->getFacebookPixelData();
21
+ $id = $data['id'];
22
+ $action = $data['full_action_name'];
23
+
24
+ ?>
25
+ <!-- Facebook Pixel Code -->
26
+ <script>
27
+ !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
28
+ n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
29
+ n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
30
+ t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
31
+ document,'script','https://connect.facebook.net/en_US/fbevents.js');
32
+
33
+ fbq('init', '<?php echo $id ?>');
34
+ fbq('track', 'PageView');
35
+
36
+ <?php if ($action == 'cms_index_index'): ?>
37
+ fbq('track', 'ViewContent');
38
+ <?php elseif ($action == 'cms_page_view'): ?>
39
+ fbq('track', 'ViewContent');
40
+ <?php elseif ($action == 'catalog_category_view'
41
+ || $action == 'catalog_category_default'
42
+ || $action == 'catalog_category_layered'): ?>
43
+ fbq('track', 'ViewContent');
44
+ <?php elseif ($action == 'catalog_product_view'): ?>
45
+ fbq('track', 'ViewContent');
46
+ <?php elseif ($action == 'catalogsearch_result_index'
47
+ || $action == 'catalogsearch_advanced_result'): ?>
48
+ fbq('track', 'Search');
49
+ <?php elseif ($action == 'customer_account_create'): ?>
50
+ fbq('track', 'CompleteRegistration');
51
+ <?php elseif ($action == 'checkout_cart_index'): ?>
52
+ fbq('track', 'AddToCart');
53
+ <?php elseif ($action == 'checkout_onepage_index'
54
+ || $action == 'onestepcheckout_index_index'
55
+ || $action == 'opc_index_index'): ?>
56
+ fbq('track', 'InitiateCheckout');
57
+ <?php elseif ($action == 'checkout_onepage_success'): ?>
58
+ <?php
59
+ $sOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
60
+ if ($sOrderId != ''): ?>
61
+ <?php
62
+ $oOrder = Mage::getModel('sales/order')->load($sOrderId);
63
+ $total = round($oOrder->getGrandTotal(), 2);
64
+ $currency = $oOrder->getOrderCurrencyCode();
65
+ ?>
66
+ fbq('track', 'Purchase', {value: '<?php echo $total ?>', currency: '<?php echo $currency ?>'});
67
+ <?php endif; ?>
68
+ <?php elseif ($action == 'wishlist_index_index'): ?>
69
+ fbq('track', 'AddToWishlist');
70
+ <?php else: ?>
71
+ fbq('track', 'ViewContent');
72
+ <?php endif; ?>
73
+
74
+ </script>
75
+ <noscript><img height="1" width="1" style="display:none" alt="Facebook Pixel"
76
+ src="https://www.facebook.com/tr?id=<?php echo $id ?>&ev=PageView&noscript=1"
77
+ /></noscript>
78
+ <!-- End Facebook Pixel Code -->
app/etc/modules/Apptrian_FacebookPixel.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Apptrian
5
+ * @package Apptrian_FacebookPixel
6
+ * @author Apptrian
7
+ * @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Apptrian_FacebookPixel>
14
+ <active>true</active>
15
+ <codePool>community</codePool>
16
+ <depends>
17
+ <Mage_Catalog />
18
+ </depends>
19
+ </Apptrian_FacebookPixel>
20
+ </modules>
21
+ </config>
app/locale/en_US/Apptrian_FacebookPixel.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ "Facebook Pixel ID is not valid.","Facebook Pixel ID is not valid."
2
+ "Info","Info"
3
+ "Facebook Pixel","Facebook Pixel"
4
+ "Apptrian Extensions","Apptrian Extensions"
5
+ "About","About"
6
+ "General","General"
7
+ "Enabled","Enabled"
8
+ "Enables or disables extension.","Enables or disables extension."
9
+ "Facebook Pixel ID","Facebook Pixel ID"
10
+ "Your Facebook Pixel ID.","Your Facebook Pixel ID."
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Apptrian_Facebook_Pixel</name>
4
+ <version>1.0.0</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>
8
+ <extends/>
9
+ <summary>Adds Facebook Pixel with standard events on appropriate pages. Passes W3C validation. Easy to install and use.</summary>
10
+ <description>Apptrian Facebook Pixel Extension for Magento adds Facebook Pixel on CMS pages (including home page), category pages, product pages, catalog search pages, catalog advanced search pages, customer registration page, cart page, checkout page (default Magento one but also IWD One Page Checkout and IDEV OneStepCheckout - others can be easily supported), checkout success page, and wishlist page. Optionally Facebook Pixel block can be added to any other Magento page or any other extension page (blogs, form pages, etc.) via xml layout updates.</description>
11
+ <notes>Initial release.</notes>
12
+ <authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
13
+ <date>2016-05-03</date>
14
+ <time>21:29:14</time>
15
+ <contents><target name="magecommunity"><dir name="Apptrian"><dir name="FacebookPixel"><dir name="Block"><dir name="Adminhtml"><file name="About.php" hash="50252d7279e670db6b55becb51bf4972"/><file name="Info.php" hash="6d198b2b2adcb85fd5d0b5f24bf30f34"/></dir><file name="Code.php" hash="e3499a4b7ffe0bac0df1ad2a60bd562d"/></dir><dir name="Helper"><file name="Data.php" hash="ce582ef825fb7071ad52da24ddd703f6"/></dir><dir name="Model"><dir name="Config"><file name="Pixelid.php" hash="628b51cbabd8539a92c9b04d621a731c"/></dir></dir><dir name="etc"><file name="config.xml" hash="ed0b1cba402da2dc0445fd40b29aa280"/><file name="system.xml" hash="864da78b1a9174f70e7ecf0873017cdb"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="apptrian_facebookpixel.xml" hash="dae666fe98a79ae417786d1a5eaec929"/></dir><dir name="template"><dir name="apptrian"><dir name="facebookpixel"><file name="code.phtml" hash="4bfcaae5b88ac9820a2633af629ba329"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptrian_FacebookPixel.xml" hash="70949175d38bd066823f7b31b2a0a53e"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Apptrian_FacebookPixel.csv" hash="1918e6bffdadf5063923338d2fb30fcd"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>8.0.0</max></php></required></dependencies>
18
+ </package>