Facebook pixel tracking

In this article, we’re going to look at setting up Facebook pixel tracking in your products and funnels.

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.

You do not need to add any further codes to your product or upsells/downsells. 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.

Using a custom success page?

Using the above method will also support custom success page redirection and the loading of purchase events prior to the redirect. You do not need to use the ThriveCart hosted success page for this method of Facebook pixel integration.


BELOW IS OUR LEGACY METHOD

This method will still continue to work and can still be used, however, we advise using the new method above, which handles all of this for you.

For your checkouts, your main scripts area is managed under your product settings in the Checkout > Tracking tab. By enabling this option and checking the box, you’ll be shown multiple fields. These fields will automatically adjust based on things like having multiple payment options (field 3) or having a bump offer (field 4) enabled on your checkout.

Basic page view tracking

To install a Facebook Pixel, you need to paste the ‘Base Pixel code’ into Field 1 in your product’s settings (see above image for Field 1 identification).

You can get your Facebook pixel code from your Facebook Ads Manager.

Copied and pasted into ThriveCart:

The code entered into Field 1 will be loaded across ALL pages in your funnel. This includes your main checkout page, any upsells/downsells, and your ThriveCart hosted success page.

If you’re wanting to track a Facebook event when a user lands on the checkout page specifically, then you can add an event code into Field 2 in your checkout tracking fields.

The specific event can be chosen in the same area where you get your Facebook pixel from. Facebook gives you a range of options on the next step and in this example below we want to add an InitiateCheckout event when the user lands on the cart page.

We can look at adding conversion values and currencies, these would be added to the fields and Facebook would automatically update the code to add to your checkout page.

Then in your product settings, this would look like:

Tracking purchase events

Tracking when a customer purchases your product, bump, upsells or downsells, this is also very easy to do. You must be using the ThriveCart hosted success page in order for this to work. If you are redirecting to your own custom success page, then you will want to load Facebook purchase events on your own pages.

Like above, with the InitiateCheckout event from Facebook, you can also get purchase events which look like this:

Now, obviously, this basic method would mean that you’d need to manually enter the purchase amount and currency for each product you add this code to.

To make things really easy for you, we’ve got some variables that can be used for the conversion value and currency which will then pull the order value and currency from the system automatically.

You’ll want to use these scripts below:

Tracking the purchase of your main product:

<script>fbq('track', 'Purchase', {value: _thrive_order.order.product.total_readable, currency: _thrive_order.order.currency});</script>

This would then be added to Field 3 in your products tracking area.

If you check the box to only run the code the first time the customer gets to the success page, this will prevent the code from running in the future if the customer clicks the link in their receipt email. This will help prevent duplicate purchase events for the same customer being run.

Tracking the purchase of your bump offer product:

<script>fbq('track', 'Purchase', {value: _thrive_order.order.bump.total_readable, currency: _thrive_order.order.currency});</script>

This would be added to Field 4 in your products tracking area.

Again, if you check the box to only run the code the first time the customer gets to the success page, this will prevent the code from running in the future if the customer clicks the link in their receipt email. This will help prevent duplicate purchase events for the same customer being run.

Upsells & downsell tracking

When it comes to your upsells and downsells, they have their own tracking scripts area in their individual products settings.

In this case, we do not need to add the Facebook base pixel for tracking. As that was added to your main product, if you attach an upsell to your funnel, it will automatically have the base Facebook pixel added to it.

You can use Field 1 to run code unique to the upsell page and code that will only run on this upsell page.

Tracking the purchase of your upsell product. Note! You must replace ‘UPSELL_ID_HERE’ in the code with the ID of your upsell, which is the number at the very end of the URL that you go to when editing the upsell.

<script>fbq('track', 'Purchase', {value: _thrive_order.order.upsells[UPSELL_ID_HERE].total_readable, currency: _thrive_order.order.currency});</script>

For example, the below upsell is 53 in my account. So the script would look like it does below.

If you check the box to only run the code the first time the customer gets to the success page, this will prevent the code from running in the future if the customer clicks the link in their receipt email. This will help prevent duplicate purchase events for the same customer being run.

Tracking the purchase of your downsell product. Note! You must replace ‘DOWNSELL_ID_HERE’ in the code with the ID of your downsell, which is the number at the very end of the URL that you go to when editing the downsell.

<script>fbq('track', 'Purchase', {value: _thrive_order.order.downsells[DOWNSELL_ID_HERE].total_readable, currency: _thrive_order.order.currency});</script>

This works in the same way as your upsells as discussed above.

Please note that the purchase events are only triggered when using ThriveCart’s hosted success page. As we control the scripts and content embedded on these pages.

If you are redirecting to your own custom success page, these codes will not be loaded consistently as your customers will often be redirected away before the codes have time to load.

If you are wanting to use purchase tracking events and your own success page you will need to embed these codes on your own page. ThriveCart provides details about your customer’s order via the query string, so it is possible to load specific scripts based on your customer’s purchases (if your funnel has multiple products). 

Related Articles