In this quick code snippet, we’ll demonstrate how you can add a Facebook tracking pixel in WooCommerce “Thank You” pages of your WooCommerce store, giving you new insight on how well your site converts Facebook users and a nice piece of information for your future marketing efforts.
What we’ll be doing is adding a custom function, so it would be worth taking a look into the article How to Safely Add Code to your Theme’s functions.php File. Additionally, you could use a great (free) plugin just for this sort of situation – My Custom Functions.
You will want to copy the entire code below, except for the beginning
<?php on line 1.
Paste it into your custom code field, then head to your Facebook administration to grab the tracking pixel you’ve already generated. Enter it in between the notated lines.
That’s all there is to it! Now, the pixel will only fire once a user gets to the order confirmation “Thank You” page. Quick, easy, and handy – the best kind of code.
Have any questions or comments about this article, or ways you think it can be improved?
Join the conversation in the comments below, or sign up for my newsletter to recieve periodic updates!