Jump to content
JuniorRodrigues

Facebook Pixel Code

Recommended Posts

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?

Share this post


Link to post
Share on other sites

How didn't it work exactly?   Did the pixel code show up in page sources ?  Which hook did you use? 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
10 hours ago, 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

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines