Installing Facebook pixel to WHMCS 7


I’ve just been banging my head against the desk trying to install the Facebook Pixel code to WHMCS 7 manually. I want to track hosting order completion to see how well Facebook ads convert.

The problem

Adding the Facebook pixel code to header.tpl hosed the WHMCS front end template.

The fix

WHMCS templates need the Facebook pixel Javascript code wrapping in {literal} tags to stop it wrecking the output.

End result:

 <!-- Facebook Pixel Code -->
 fbq('init', '123456'); // Insert your pixel ID here.
 fbq('track', 'PageView');
 <noscript><img height="1" width="1" style="display:none"
 <!-- DO NOT MODIFY -->
 <!-- End Facebook Pixel Code -->

I’ve changed my pixel ID to 123456 – so don’t copy and paste this code. Note the {literal} tags before and after the Facebook code.