I have been trying to implement the new Facebook Tracking Pixel to track conversion in a Magento store.
I have the base pixel code in the head tags
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue= [];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', 'PIXELID');
fbq('track', "PageView");</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=PIXELID&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
I have then found the success.phtml file within the themes directories as added the following code as per my understanding when reading the Facebook documentation I have found;
<?php
//Get Order Number & Order Total
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$amount = number_format($order->getGrandTotal(),2);
?>
<script>
// Purchase
// Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)
fbq('track', 'Purchase', {'value': '<?php echo $amount; ?>', 'currency': 'GBP'});
</script>
<noscript>
<img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=PIXELID&ev=Purchase&cd[value]=<?php echo $amount; ?>&cd[currency]=GBP&noscript=1"/>
</noscript>
The above code isn't sending any data at all upon placing an order via a Facebook ad click. Can anyone shed any light as to what I am doing wrong?
Related
Can the {value: '0.00'} parameter be used with all 9 predetermined Facebook events for conversion tracking? For example, I am trying to say that a Search is worth 2.30. This is not a monetary value however, so I was leaving out the currency. Will this show up in Facebook's system?
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '924082587688070');
fbq('track', "PageView");
fbq('track', 'Search', {value: '2.30'});
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=924082587688070&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
As far as I have read, this is valid for all the facebook standard events. If you do not supply a currency I am pretty sure facebook will use the currency you have registered for you account.
complicated situation, i'll try to be as clear as possible.
I have a one page site with a contact form, index.html.
The page has the following remarketing facebook pixel:
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '123456789');
fbq('track', "PageView");</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=123456789&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
When a user submit the form, and i get a response from the ajax, I load an external html file to an iframe on my page (conv.html).
that external html file has a conversion code in it:
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '123456789');
fbq('track', "PageView");
fbq('track', 'Lead');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=123456789&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
which is basically the same, only with a 'Lead' track event.
as you can see im using 'PageView' on both pixels in order to exclude by the url audience who has submited the form (i need that in addition to the lead event), the thing is, that when i load the second pixel, i get an error saying that the pixel was fired more than once.
im not sure if that any matters, but we have also applied a rule to the second pixel to fire only on page url that contains 'conv.html' (the page that is loaded to my iframe).
i have been look around on google for a solution, but couldnt find anything.
im trying to figure out if thats even possible on a one page site.
any ideas?
I would like to know how to show a CQ5 page in a Facebook App without writing a dedicated sling servlet?
Facebook adds a form post to retrieve markup and insert into the iFrame.
Apparently, CQ5 pages doesn't allow POST operations unless you write a dedicated sling servlet to handle.
The page for some reason sits within /content/dam
Here's what the Facebook App add in the canvas:
<form action="<url>" method="post" target="iframe_canvas_fb_https" id="canvas_iframe_post_522050a15f2c72f17540952" onsubmit="return window.Event && Event.__inlineSubmit && Event.__inlineSubmit(this,event)"><input type="hidden" autocomplete="off" name="signed_request" value="TKQ-UKDi8meFDQgQaq_5c3LWD2R06EiibRdrTk7XldE.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM3Nzg0OTUwNSwidXNlciI6eyJjb3VudHJ5IjoiaGsiLCJsb2NhbGUiOiJlbl9HQiIsImFnZSI6eyJtaW4iOjIxfX19"><input type="hidden" autocomplete="off" name="locale" value="en_GB"></form>
<iframe class="smart_sizing_iframe" frameborder="0" scrolling="yes" id="iframe_canvas" name="iframe_canvas_fb_https" src='javascript:""' height="800" webkitallowfullscreen="" mozallowfullscreen="" oallowfullscreen="" msallowfullscreen="" style="height: 232px;"></iframe>
I have this code for a Facebook custom share button:
<script>
function fbs_click() {
u=location.href;
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank" class="fb_share_link">
<img src="../../../../../image/photography/pics/fb-share.png" alt="Share this!" width="57" height="21" border="0">
</a>
This is supposed to scrape info from the page but for some reason it doesn't and it gets redirected to the site's main index.html.
I've tried adding facebook og tags and the extra code in the but to no avail.
Any thoughts?
EDIT: Having been told that the share function has been deprecated, I tried to do this with the feed dialog:
<a href="https://www.facebook.com/dialog/feed?link=http://www.travel2italy.com/Travel/Italy/Company/photography/index.html&picture=http://www.travel2italy.com/image/photography/pics/homepage/florence1-home.jpg&name=travel2italy.com&caption=Photo%20Gallery&description=A%20Beautiful%20photo%20of%20Florence&redirect_uri=http://www.travelive.com" target="_blank">
<img src="../../../../../image/photography/pics/fb-share.png" alt="Tweet this!" width="57" height="21" border="0">
</a>
but when i click on the link it takes me to facebook and says an error occured, wth?!:(
EDIT 2:
I wasn't aware that the app_id argument is needed, signed up for an app and it works now, but it strips away the #section I have at the end of the link (i want it to link to a specific slide in a slideshow)
EDIT 3:
Now some of the share buttons using the sharer do seem to work but don't pull all the photos off the page for me to choose the one i want, this is insane-o, could it just be a caching issue?
I'm using Facebook Like on my product pages. When somebody like's a product the wrong tekst and image is displayed on the Timeline of the User. Pinterest and Twitter are working okay.
I use Opencart version 1.5.2.1 and my buttons are from Addthis. The Pinterest button is modified for Opencart. The code i use is:
<div class="share"><!-- AddThis Button BEGIN --> <div
class="addthis_toolbox addthis_default_style "> <a
class="addthis_button_pinterest" pi:pinit:url=<?php echo
$breadcrumb['href']; ?> pi:pinit:media=<?php echo $thumb; ?>
pi:pinit:layout="none"></a> <a class="addthis_button_tweet"
tw:count="none"></a> <a class="addthis_button_facebook_like"
fb:like:width="85" /></a> </div> <script type="text/javascript"
src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f68526319f4252e"></script>
<!-- AddThis Button END -->
If someone is able to help me with this it would be very appreciated.
It was a user agent problem.
Facebook was not able to see my page.
It is solved now by putting the user agent in array.