1. Home
  2. Custom Scripts & Codes
  3. Facebook pixel tracking

Facebook pixel tracking

In this article, we’re going to take a closer look at integration with Facebook so that things like your checkout views and purchases are reported back to Facebook effectively.

There are two methods of integrating with Facebook and we’re going to cover both below:

  1. Facebook Pixel (client-side Javascript tracking)
  2. Facebook’s CAPI (server-side notifications)

The most popular and most commonly used method of integration with Facebook for almost all platforms is done by using their Javascript pixel code. This is the script Facebook provides users to place on their website and when those scripts are loaded, those events are then passed back to Facebook.

Whilst this is the most common method, it’s also the most unreliable.

As more and more browsers and extensions are releasing features to help with user privacy, more things look to block those events and tracking events from getting sent back to Facebook. So if for any reason that script can’t be loaded on the user’s device, no data will get passed back to Facebook.

A more reliable method of sending data is server-side notifications, this is something that triggers in the background and removes all dependency on scripts loading on the users device and the impact of adblockers.

Below we’re going to cover how to set each option up and how they work.

1. Standard Facebook Pixel

Under your product settings, you’ll need to go to Checkout > Tracking

Here you can enable the option for Facebook, and you’ll need to enter your Facebook Pixel ID into the field.

Once done, you can save your product, and your Facebook pixel and purchase event tracking is now saved into your product and funnels.

Important: You do not need to add any further codes to your product or upsells/downsells.

Important: If you are running Facebook ads and you want to associate purchase events with these ads, you will need to ensure you’re running a custom subdomain within ThriveCart. This is because Facebook will now only track events to domains that you own and have verified in your dashboard. See this article on Facebook domain verification for more details.

ThriveCart will automatically handle your Facebook codes throughout this products funnel and report back to Facebook:

  • PageView (default, loaded on each page in the funnel)
  • InitiateCheckout (when loading the initial checkout page)
  • Purchase (loaded on the success page or before redirecting to your custom success page and for each product the customer purchased in the funnel).

In addition to the Purchase event, as part of this we include content_type: productand the Id of the product, for example, product-xxbump-xx, upsell-xx, and downsell-xx where ‘xx’ would be the product ID from your account.

We also include the amount the customer paid at checkout, taking into account any discounts. The currency is also automatically passed through based on the currency of your product.

Using a custom success page?

When running a custom success page, the ThriveCart hosted success page is briefly loaded in the background prior to redirecting to your custom page (the customer doesn’t see this).

We have a short delay to try and give time for 3rd-party scripts (like this) to fire and report back, however depending on the users device, internet speed, and the time it takes for your site to load it could be possible that the purchase event doesn’t have time to load before the customer is taken to your site (if the event isn’t being blocked from the notes in the top of this article).

2. Facebook Conversion API (CAPI)

By using our CAPI integration, we’ll automatically disable the Facebook Pixel events from loading on your pages within your funnel (with the exception of the PageView events – these will still continue).

This is because these events will now be reported in the background.

The events we support with this are as follows:

  • InitiateCheckout
  • ViewContent
  • Purchase
  • Lead (on cart bounce)

By default, we send one purchase event for every item in the funnel that was bought. As an example, if you buy the Product, Bump and an Upsell, that’s 3x Purchase events with info for each one. You can check the box to ‘combine charges’ to send a single purchase event for the entire order.

By default, the domain applied will be that of your ThriveCart account ( xxx.thrivecart.com ) or of your Custom domain (when enabled). You can override this to another domain that you have verified within Facebook if you wish.

The InitiateCheckout and ViewContent events are sent as the customer is sat on the page – they’re sent through our server and not directly through the Pixel, and Pixel events are not triggered at all if the server-side tracking is enabled.

The Purchase events are triggered asynchronously, and so happen regardless of whether the user abandons or hits the cart page etc. This is similar to how webhooks work, where they are reliable all the time no matter what user behaviour is.

The Lead event will be triggered in the event the customer bounces from the cart.

We do not use de-duplication and all events are communicated via the backend. If you enable this CAPI, we do not track anything in the browser directly.

To enable CAPI support, after entering your Facebook Pixel ID in the field, check the box to enable the Conversion API.

To get the Conversion API Access code, you can follow the instructions below. Please note that this is subject to change at any time at Facebook as they regularly change processes.

Load up the Facebook Ads Manager and head over to the Events Manager area. Make sure you select the same Pixel as you’ve entered in your Pixel ID field.

Then you’ll want to click the button Add Events and select the option “Using the Conversions API”

On the next screen, you’ll want to make sure you choose the option to Install Code Manually

Next, you’ll want to ensure you’re under e-Commerce & retail and then select the View Content, Initiate Checkout, and Purchase events (these are what we’ll pass back).

After selecting these events, there is a couple of fields you will need to ensure are selected for each event. If you check the Client user agent – do no hash option, this will automatically check the other one.

Facebook will show you a summary of these 3 events and they should all match like below.

Finally, You need to click the link Open implementation guide. This will launch a new tab/window.

In the new window that was opened, you’ll need to click the Generate Access Token button.

Make sure to keep a record of this token and save it for future use. Facebook will not show it to you again.

You can then close this window, and click on the Finish button back in the original setup area.

You will want to save this Access Token in the Conversions API access code field (shown above in your products settings).

You can use this access token across multiple products in your account as it’s associated with that Facebook Pixel.

Now you can save your product and ThriveCart will handle everything with Facebook around this event reporting for this product.

Testing CAPI

You can use the Conversions API’s ‘Test server events’ functionality to verify that your access code is working correctly. This also allows you to test your product without reporting your actions as live events into Facebook.

When you’re ready to take live orders and pass real event data to Facebook, you will want to remove this test code from your product’s settings.

You can get the ‘test event code’ from the test events tab:

When this code is added to your product in ThriveCart, all your events for the CAPI will be passed through associated as test events. This code changes once every 24 hours.

Updated on April 15, 2021

Was this article helpful?

Related Articles

Can't find the answer?
Can't find the answer to your question after searching the helpdesk and our extensive content? Click below to submit a ticket and get in touch with us.
Submit A Ticket