Version Notes
Initial release Facebook tracking pixel integration.
Download this release
Release Info
Developer | Eke Digital |
Extension | Eke_Facebook |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Eke/Facebook/Helper/Data.php +14 -0
- app/code/community/Eke/Facebook/etc/adminhtml.xml +23 -0
- app/code/community/Eke/Facebook/etc/config.xml +45 -0
- app/code/community/Eke/Facebook/etc/system.xml +48 -0
- app/design/frontend/base/default/layout/eke_facebook.xml +8 -0
- app/design/frontend/base/default/template/eke/facebook/tracker.phtml +43 -0
- app/etc/modules/Eke_Facebook.xml +9 -0
- package.xml +18 -0
app/code/community/Eke/Facebook/Helper/Data.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Eke_Facebook_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
public function isTrackerPixelEnabled()
|
5 |
+
{
|
6 |
+
return Mage::getStoreConfig("eke_facebook/tracker/enabled");
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getTrackerPixelId()
|
10 |
+
{
|
11 |
+
return Mage::getStoreConfig("eke_facebook/tracker/pixel_id");
|
12 |
+
}
|
13 |
+
|
14 |
+
}
|
app/code/community/Eke/Facebook/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 |
+
<eke_facebook>
|
12 |
+
<title>Eke Digital Facebook Tracking Pixel</title>
|
13 |
+
<sort_order>990</sort_order>
|
14 |
+
</eke_facebook>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/community/Eke/Facebook/etc/config.xml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Eke_Facebook>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Eke_Facebook>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<eke_facebook>
|
11 |
+
<class>Eke_Facebook_Model</class>
|
12 |
+
<resourceModel>eke_facebook_resource</resourceModel>
|
13 |
+
</eke_facebook>
|
14 |
+
<eke_facebook_resource>
|
15 |
+
<class>Eke_Facebook_Model_Resource</class>
|
16 |
+
</eke_facebook_resource>
|
17 |
+
</models>
|
18 |
+
<blocks>
|
19 |
+
<eke_facebook>
|
20 |
+
<class>Eke_Facebook_Block</class>
|
21 |
+
</eke_facebook>
|
22 |
+
</blocks>
|
23 |
+
<helpers>
|
24 |
+
<eke_facebook>
|
25 |
+
<class>Eke_Facebook_Helper</class>
|
26 |
+
</eke_facebook>
|
27 |
+
</helpers>
|
28 |
+
</global>
|
29 |
+
<frontend>
|
30 |
+
<layout>
|
31 |
+
<updates>
|
32 |
+
<eke_facebook>
|
33 |
+
<file>eke_facebook.xml</file>
|
34 |
+
</eke_facebook>
|
35 |
+
</updates>
|
36 |
+
</layout>
|
37 |
+
</frontend>
|
38 |
+
<default>
|
39 |
+
<eke_facebook>
|
40 |
+
<tracker>
|
41 |
+
<enabled>0</enabled>
|
42 |
+
</tracker>
|
43 |
+
</eke_facebook>
|
44 |
+
</default>
|
45 |
+
</config>
|
app/code/community/Eke/Facebook/etc/system.xml
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<eke>
|
5 |
+
<label>EKE DIGITAL</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</eke>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<eke_facebook translate="label">
|
11 |
+
<label>Facebook Tracking Pixel</label>
|
12 |
+
<tab>eke</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 |
+
<tracker translate="label">
|
20 |
+
<label>Configuration</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="eke_facebook">
|
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>Tracking 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 |
+
</pixel_id>
|
43 |
+
</fields>
|
44 |
+
</tracker>
|
45 |
+
</groups>
|
46 |
+
</eke_facebook>
|
47 |
+
</sections>
|
48 |
+
</config>
|
app/design/frontend/base/default/layout/eke_facebook.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<block type="core/template" template="eke/facebook/tracker.phtml" />
|
6 |
+
</reference>
|
7 |
+
</default>
|
8 |
+
</layout>
|
app/design/frontend/base/default/template/eke/facebook/tracker.phtml
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$helper = Mage::helper("eke_facebook");
|
3 |
+
if (!$helper->isTrackerPixelEnabled()) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
$id = $helper->getTrackerPixelId();
|
7 |
+
?>
|
8 |
+
|
9 |
+
<!-- Facebook Pixel Code-->
|
10 |
+
<script>
|
11 |
+
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
12 |
+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
|
13 |
+
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
|
14 |
+
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
|
15 |
+
document,'script','//connect.facebook.net/en_US/fbevents.js');
|
16 |
+
fbq('init', '<?php echo $id ?>');
|
17 |
+
fbq('track', "PageView");
|
18 |
+
|
19 |
+
<?php
|
20 |
+
$request = $this->getRequest();
|
21 |
+
$module = $request->getModuleName();
|
22 |
+
$controller = $request->getControllerName();
|
23 |
+
$action = $request->getActionName();
|
24 |
+
|
25 |
+
if(Mage::registry('current_product')) {echo "fbq('track', 'ViewContent');"; }
|
26 |
+
if($controller == 'result' || $controller =='advanced') { echo "fbq('track', 'Search');"; }
|
27 |
+
if($module == 'customer' && $controller == 'account' && $action == 'index'){echo "fbq('track', 'CompleteRegistration')";}
|
28 |
+
if($module == 'checkout' && $controller == 'cart' && $action == 'index') {echo "fbq('track', 'AddToCart');"; }
|
29 |
+
if($module == 'wishlist') { echo "fbq('track', 'AddToWishlist');"; }
|
30 |
+
if($module == 'checkout' && $action == 'index') { echo "fbq('track', 'InitiateCheckout');"; }
|
31 |
+
if($module == 'checkout' && $action == 'success') {
|
32 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
33 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
34 |
+
$total = round($order->getGrandTotal(), 2);
|
35 |
+
$currency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
36 |
+
echo "fbq('track', 'Purchase', {value: '$total', currency: '$currency'});";
|
37 |
+
}
|
38 |
+
?>
|
39 |
+
|
40 |
+
</script>
|
41 |
+
<noscript><img height="1" width="1" style="display:none" src=" https://www.fbpixel.com/tr?id=<?php echo $id ?>&ev=PageView&noscript=1" /></noscript>
|
42 |
+
<!-- End Facebook Pixel Code -->
|
43 |
+
|
app/etc/modules/Eke_Facebook.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Eke_Facebook>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Eke_Facebook>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Eke_Facebook</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Facebook tracking pixel integration extension for Magento.</summary>
|
10 |
+
<description>This extension integrations the Facebook tracking pixel and tracks events.</description>
|
11 |
+
<notes>Initial release Facebook tracking pixel integration.</notes>
|
12 |
+
<authors><author><name>Eke Digital</name><user>ekedigital</user><email>dane@ekedigital.com</email></author></authors>
|
13 |
+
<date>2016-09-11</date>
|
14 |
+
<time>01:46:22</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Eke"><dir name="Facebook"><dir name="Helper"><file name="Data.php" hash="fafa66007e137e4ca8bcf75033f14627"/></dir><dir name="etc"><file name="adminhtml.xml" hash="70388eac316c72e69c41d267180b200b"/><file name="config.xml" hash="12c1dfde8fe42b2eca87049d8ceaae3c"/><file name="system.xml" hash="b416e03fdf2f18f1111a8cb6184df22d"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="eke"><dir name="facebook"><file name="tracker.phtml" hash="6e843cf236e8553ae5186fa66f43e673"/></dir></dir></dir><dir name="layout"><file name="eke_facebook.xml" hash="b4f8c22bfb782fdf80b196e4d3f12205"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eke_Facebook.xml" hash="d0d055838e8b56b18c889fa4ed68a3b1"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Helper_Abstract</name><channel>community</channel><min>1.6</min><max>1.9</max></package></required></dependencies>
|
18 |
+
</package>
|