News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Insert Facebook Conversion Code into Head tag of Checkout Thank you page

Started by microtribe, June 17, 2014, 03:23:47 AM

Previous topic - Next topic

microtribe

Hi. I need to insert Facebook's Conversion Tracking code into the <head> tag of the order_done.php page. I know how to add Google's tracking code to the body, but do not know how to add Facebook's code to the Head tag. Can anyone help? I have  a third party extension installed, but it just offers the ability to add the code to a published article page, and the checkout thank you page is not a published article.

Thank you,
Tony

GJC Web Design

something like


$script = 'YOUR SCRIPT HERE';
$doc = JFactory::getDocument();
$doc->addScriptDeclaration( $script );

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

microtribe

Nope, that doesn't work. Something about the syntax of the script messes it up when I drop it into YOUR SCRIPT HERE. Below is the script. I've overwritten my personal numeric code with NUMBER for security.

<script>(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
  }
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', 'NUMBER', {'value':'0.00','currency':'USD'}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=NUMBER&amp;cd[value]=0.00&amp;cd[currency]=USD&amp;noscript=1" /></noscript>

GJC Web Design

of course - you will have to escape etc your script - you asked how to insert JS in the head on a Joomla install - that is how

to get your script in a condition to do that is html 101 - Google
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

powerguy2011

yes I was wondering why there is no thread about this.

the new facebook conversion tool it very useful but somehow its not working when I do the steps as facebook guide,

they asked to copy the entire pixel code and add it into all php files of the website in <head> tags and then when making the campaign choose the pages u need to track,

1- there are a lot of files in joomla and virtuemart is it really necessary to do that

2- I inserted the code in some files and fixed the campaign to track it, however its not working I don't know why

I am a beginner and don't know about coding but in facebook tutorial it mentioned not to edit the code,

can anyone help?

powerguy2011

hey guyz !

I want to give this a second try, can anyone tell me what is the file name for the thankyou page after checkout knowing that I use VM version 1.2.0 b stable

jenkinhill

VirtueMart 1.2b is not supported on this forum. It was a privately produced version of VM1.1.9 modified to work with Joomla2.5 for those who for one reason or another could not migrate their site to use VM2 at that time. See http://forum.virtuemart.net/index.php?topic=99339.0   
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

powerguy2011


microtribe

Hey folks. The solution I came up with was to create a custom Thank You page that the cart redirects to at checkout. I was then able to install the FB conversion pixel and it works. The only downside is that this is a static html page, so it has to be updated if the main menu changes.

sebmolo

I'm really interested in that matter, as i need to implement the facebook conversion pixel in the checkout page.
Can anybody help me to insert the code the right way?
Thanks in advance!

microtribe

UPDATE: With the new Facebook pixel, you no longer need to add the code to your thank you page or order_done.php page. You just add the main pixel to your template index.php file in the head area. Then in Facebook, create a Custom Conversion item and use the URL for your checkout: http://www.yourwebsite.com/store/cart