Facebook PageView event code for SquareSpace Site
In this Article we will see how we can integrate the Facebook PageView Pixel which will track each and every visit from the Visitors of Facebook Ad.We will also discuss how to track Purchase event of your Facebook Pixel.
- Log into your Squarespace account and click on Settings.
- At the bottom of the Website section on the left-hand menu, click on Advanced.
-
-
Click on Code Injection.
- Paste the Pixel in the box under Header.
<!-- 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', 'YourPixelId');//Please Replace with yourPixel Id Like 336288036710618
fbq('track', 'PageView');
</script>
<!-- End Facebook Pixel Code -->
And you’re done!
-
This will Track Page Visit so while pasting code make sure it has fbq(‘track’,’PageView’);
Now we will start how to Integrate the Facebook Purchase event to start tracking purchases using your Facebook pixel, you’ll need to copy the purchase event code below and paste it on your website.
Facebook Purchase event code for SquareSpace Site
<script type="text/javascript">
window.onload = function() {
window._fbq.push('track', 'Purchase', {
content_id: '{orderId}',
value: '{orderGrandTotal}',
currency: 'USD'
});
};
</script>
Go to Squarespace Site and click Settings. Then click Advanced and Code Injection.
Paste above purchase code under Order Confirmation Page.
Click Save. You’ve now completed setting up Facebook purchase event code on your website and can measure purchases resulting from your Facebook advertising.