JuniorRodrigues Posted February 6, 2019 Share Posted February 6, 2019 Hi people, I wanna put the Facebook Pixel Code on my Cart to follow more details on Facebook Business. I've tried to put it using hook but didn't work. Do someone know how to do it? 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 7, 2019 Share Posted February 7, 2019 How didn't it work exactly? Did the pixel code show up in page sources ? Which hook did you use? 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted February 7, 2019 Share Posted February 7, 2019 (edited) There is a commercial module in Marketplace, but you can add the code to footer.tpl. https://marketplace.whmcs.com/product/358 If you want to do it only for cart, put {if $templatefile == 'viewcart'} before, to include it only to viewcart page. Edited February 7, 2019 by pRieStaKos 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 7, 2019 Share Posted February 7, 2019 7 hours ago, pRieStaKos said: you can add the code to footer.tpl. if you were going to do that, you'd be better off using a clientarea output hook rather than editing the template. the free addon module below should still work - though it's 3 years old, so the specific Facebook pixel code within might need to be changed if it has been updated by Facebook since then... https://github.com/StrikeHawk-ecommerce/whmcs-facebook-pixel-tracking you would need to change the folder name to "facebookpixel" within the addons folder for this to be visible to the addons page. 0 Quote Link to comment Share on other sites More sharing options...
JuniorRodrigues Posted February 8, 2019 Author Share Posted February 8, 2019 Hi Guys! Thanks for help me. I resolved it doing; 1) Open the file "header.tpl" on your Template folder 2) Before the tag "</head>" put this code below changing the ID "123456" to your pixel id: {literal} <!-- 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','https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '123456'); // Insert your pixel ID here. fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=123456&ev=PageView&noscript=1" /></noscript> <!-- DO NOT MODIFY --> <!-- End Facebook Pixel Code --> {/literal} Now it is working fine. I hope to help someone. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 8, 2019 Share Posted February 8, 2019 (edited) On 08/02/2019 at 01:12, JuniorRodrigues said: Now it is working fine. I hope to help someone. I assume that you realise that this code is going to get overwritten during your next WHMCS update - you'd be better off putting that code into a headoutput hook as the free addon I linked to does. the attached hook should do the same as your edited template - though obviously don't use both. facebookpixel.php Edited September 12, 2019 by brian! 3 Quote Link to comment Share on other sites More sharing options...
JuniorRodrigues Posted February 23, 2019 Author Share Posted February 23, 2019 Thanks so much! 0 Quote Link to comment Share on other sites More sharing options...
The Stratega Posted April 29, 2020 Share Posted April 29, 2020 This hook worked and was able to be verified immediately for my Facebook Pixel. Create a file. ( I named it FBPixel.php ) in: /includes/hooks/FBPixel.php Add the following code and replace 123456 for your Pixel Id. or copy your pixel code in between the "return <<<HTML and HTML;" tags. Save and test your pixel. Mine was immediately verified. You can also view the source code of your page and you can see the pixel code below there. Hope this helps. JC <?php /** * Facebook Pixel Code * @author JC */ add_hook('ClientAreaHeadOutput', 1, function($vars) { return <<<HTML <!-- 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', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '123456'); //Your pixel ID here. fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=123456&ev=PageView&noscript=1" /></noscript> <!-- End Facebook Pixel Code --> HTML; }); 0 Quote Link to comment Share on other sites More sharing options...
Dave_Johns Posted January 7, 2021 Share Posted January 7, 2021 hi @The Stratega With this code can you track sales? Best, D 0 Quote Link to comment Share on other sites More sharing options...
Dave_Johns Posted January 7, 2021 Share Posted January 7, 2021 Hi @brian! sorry for bother! I need to start tracking sales, that means to paste a pixel in /cart.php?a=complete . This hook that you have shared could work? Thanks in advance D. 0 Quote Link to comment Share on other sites More sharing options...
JamesN Posted December 3, 2021 Share Posted December 3, 2021 On 1/7/2021 at 8:52 AM, Dave_Johns said: Hi @brian! sorry for bother! I need to start tracking sales, that means to paste a pixel in /cart.php?a=complete . This hook that you have shared could work? Thanks in advance D. Sorry for bumping an old thread. Any luck with that though? I am also looking for a hook to add a script after payment complete (on success). 0 Quote Link to comment Share on other sites More sharing options...
Magijutsu Posted October 24, 2023 Share Posted October 24, 2023 On 2/7/2019 at 8:12 PM, JuniorRodrigues said: Hi Guys! Thanks for help me. I resolved it doing; 1) Open the file "header.tpl" on your Template folder 2) Before the tag "</head>" put this code below changing the ID "123456" to your pixel id: {literal} <!-- 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','https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '123456'); // Insert your pixel ID here. fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=123456&ev=PageView&noscript=1" /></noscript> <!-- DO NOT MODIFY --> <!-- End Facebook Pixel Code --> {/literal} Now it is working fine. I hope to help someone. I used this solution in a custom template. So far so good. 0 Quote Link to comment Share on other sites More sharing options...
bdshapers Posted January 29 Share Posted January 29 Thank you guys! it works with the both way.! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.