Facebook Pixel Code

Facebook Pixel Code

healthandvitals
Tourist
6 0 1

Hello! I have set up my facebook pixel code into my theme.liquid section, however, I cannot seem to find where I can add my purchase event. I am using Debutify theme. There is nothing to edit under the settings-checkout and nowhere do I see order processing or add additional scripts. 

Replies 4 (4)

goldi07
Trailblazer
181 14 19

Hello @healthandvitals 

 

In Shopify, the Purchase event should be added on the order confirmation page. However, since Shopify removed the option to add scripts in the checkout settings for most plans, you need to add it through the Checkout Thank You Page (Order Status Page) or directly within your theme files.

 

Method 1: Adding the Purchase Event in theme.liquid (Debutify)
Since you've already added your Facebook Pixel in theme.liquid, you can manually fire the Purchase event inside the order confirmation page.

Steps:
1.Go to Online Store → Themes → Actions → Edit Code.

2.Open theme.liquid.

3.Scroll to the bottom, right before </body>, and add:

{% if template == 'checkout.thank_you' %}
<script>
    fbq('track', 'Purchase', {
        value: {{ checkout.total_price | money_without_currency }},
        currency: '{{ checkout.currency }}'
    });
</script>
{% endif %}

 4.Click Save.

 

This code ensures that the Purchase event fires only on the order confirmation page.

 

Method 2: Adding the Purchase Event via Shopify Settings (For Shopify Plus)
If you are on Shopify Plus, you can add the Purchase event in:

. Settings → Checkout → Additional Scripts (Only available for Shopify Plus)

. Add the same fbq('track', 'Purchase', {...}); script.

Since you're using Debutify, the first method should work for you.

 

Thank you 😊

 

Was I helpful?

Buy me a coffee



Want to modify or custom changes or bug fix on store . Or Need help with your store? Or -Want Complete Storefront
Email me -Goldi184507@gmail.com - Skype: live:.cid.819bad8ddb52736c -Whatsapp: +919317950519
Checkout Some Free Sections Here

Sushant
Shopify Partner
90 2 16

Hi @healthandvitals ,

Placing facebook pixel code directly in the theme code is one way of integrating facebook pixel in your store, however it is not advisable. This method of integration is only used when there are complex use cases. In case you have a standard setup, the method of integrating facebook pixel with Shopify which works for 95% of the stores is to use Facebook & Instagram Sales channel in Shopify. Under sales channel in your Admin, search for Facebook & Instagram. Install the sales channel and configure the settings. This will not only setup your facebook pixel, but also your catalog feed for ads.

Sushant_0-1743062971473.png

Hope this helps.

 

Any Likes and Accept as Solutions are greatly appreciated✌ Having trouble? Hire us! https://seventhtriangle.com/
healthandvitals
Tourist
6 0 1

Thanks for the reply. I have a personal facebook account with 2 business portfolios. Both ad accounts on those portfolios are disabled from advertising in which I cannot use the facebook sales channel app to connect to my pixel (because the pixel is linked to the business account) so I am now stuck with using my personal ad account and Shopify will not let me connect my personal ad account pixel to the facebook app. Do you have any advice? Is there a way I can connect my personal ad account pixel? Or should I create a new facebook account?

Sushant
Shopify Partner
90 2 16

Hi @healthandvitals , In this case you have 2 options:

1. Using a Shopify App.

https://apps.shopify.com/onepixel

https://apps.shopify.com/pixelfy-facebook-pixels

 

2. Custom coding using Shopify Customer Events

To set this up:

Step 1.  Go to Settings>Customer Events>Add Custom Pixel.

Here you can add the code for all facebook pixel events.

Shopify has shared a tutorial for this as well. Please see the code and other aspects of customer events on the below links.

https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/code#custom-pixel-exampl...

https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/code

 

Any Likes and Accept as Solutions are greatly appreciated✌ Having trouble? Hire us! https://seventhtriangle.com/