Facebook Pixel Setup



This article is considered advanced and outside regular Neto support. Neto offers this installation as a paid professional service.

If your theme was installed prior to 29th August 2016, please follow our Legacy Facebook Pixel instructions for installation instructions.

About Facebook Pixel

The Facebook pixel allows you to place a single pixel across your entire website to report conversions, build audiences and get rich insights about how people use your website.

Overview

Facebook pixel is complex however if you comfortable installing the Facebook Pixel script yourself, this article explains what you will need to do.

As this involves making changes to your web store’s theme template, if you change your theme, the products will no longer be passed to Facebook.

Currently the Add to Cart event is not compatible with Neto.

In this article we will cover:

  • Installing the Facebook Pixel script on all pages on your site, including the ‘Order Confirmation’ page.
  • Changing the theme so the product details are passed to Facebook.
  • Testing the installation.

Getting Started

  1. We need to create a new third party script and call it Facebook Pixel. From the Neto dashboard, navigate to Setup & Tools > All settings & tools.

  2. Click Analytics & 3rd Party Scripts tab > click Custom Scripts.

  3. Click Add New button on the top right hand side.

  4. Under Name, call the script: Facebook Pixel.

  5. If you haven’t already created a Facebook Pixel, simply follow the Facebook instructions. Once created, a popup will show with your Pixel ID.


  6. Add the Facebook Pixel ID under Key 1.

  7. Scroll down to the Scripts section and click the Page Footer tab. Add the following script here -

  8. Facebook say to put it in the HEAD tag but it needs to be in the footer.

    [%if [@config:current_page_type@] eq 'product'%]    [%set [@facebook_track@]%]ViewContent[%/set%]
        [%set [@facebook_extra@]%], { 
            content_name: '[%url_encode%][@name@][%/url_encode%]', 
            content_category: '[%CONTENT_PATH id:'[@inventory_id@]' type:'category' limit:'1'%][%PARAM *body%][%url_encode%][@content_name@][%/url_encode%][%END PARAM%][%END CONTENT_PATH%]', 
            content_ids: ['[@sku@]'],
            content_type: 'product',
            value: [@price@], 
            currency: '[@CONFIG:DEFAULTCURRENCY@]' 
        }[%/set%]
    [%elseif [@config:current_page_type@] eq 'category' and [@form:rf@] eq 'kw'%]    [%set [@facebook_track@]%]Search[%/set%]
        [%set [@facebook_extra@]%], { 
            search_string: '[%url_encode%][@form:kw@][%/url_encode%]' 
        }[%/set%]
    [%elseif [@config:current_page_type@] eq 'category'%]    [%set [@facebook_track@]%]ViewContent[%/set%]
        [%set [@facebook_extra@]%], { 
            content_name: '[%url_encode%][@content_name@][%/url_encode%]',
            content_type: 'product', 
            content_ids: [''[%site_value id:'facebook-pixel' type:'load'/%]]
        }[%/set%]
    [%elseif [@config:current_page_type@] eq 'checkout' and [@CONFIG:GA_FUNNEL_VALUE@] eq '/purchase/shopping_cart.html'%]    [%set [@facebook_track@]%]InitiateCheckout[%/set%]
        [%set [@facebook_extra@]%][%/set%]
    [%elseif [@config:current_page_type@] eq 'checkout' and [@CONFIG:GA_FUNNEL_VALUE@] eq '/purchase/confirmation.html'%]    [%set [@facebook_track@]%]AddPaymentInfo[%/set%]
        [%set [@facebook_extra@]%][%/set%]
    [%else%]    [%set [@facebook_track@]%][%/set%]
        [%set [@facebook_extra@]%][%/set%]
    [%/if%]<!-- 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','//connect.facebook.net/en_US/fbevents.js');
        fbq('init', '[@REFERRAL_KEY1@]');
        fbq('track', 'PageView');
        [%if [@facebook_track@] ne ''%]
            fbq('track', '[@facebook_track@]'[@facebook_extra@]);
        [%/if%]
    </script>
    <noscript>
            <img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=[@REFERRAL_KEY1@]&ev=PageView&noscript=1" />
    </noscript>
    <!-- End Facebook Pixel Code -->
    
    
  9. Now click on the Purchase Confirmation (Thank You Page) tab and add the following script:
  10. <!-- 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','//connect.facebook.net/en_US/fbevents.js');
        fbq('init', '[@REFERRAL_KEY1@]');
        fbq('track', 'PageView');
        fbq('track', "Purchase", {
            content_type: 'product', 
            content_ids: [''[%show_order id:'[@order_id@]'%][%param *body%],'[@sku@]'[%/param%][%/show_order%]], 
            value: [@grand_total@], 
            currency: '[@CONFIG:DEFAULTCURRENCY@]'
        });
    </script>
    <noscript>
            <img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=[@REFERRAL_KEY1@]&ev=PageView&noscript=1" />
    </noscript>
    <!-- End Facebook Pixel Code -->
    
  11. Click on the Product Thumbnails tab and add the following script:

    [%site_value id:'facebook-pixel'%],'[@sku@]'[%/site_value%]

  12. Save the third party script.

  13. You can test using Facebook Pixel Helper plugin for Chrome. Use the plugin to test the Home, a product category, product, shipping cart, checkout and order confirmation pages. The plugin will tell you if there are any errors.


If you get an error while testing, you may need to change your Facebook settings. Simply navigate to https://www.facebook.com/settings?tab=ads, change the option 'Adverts based on my use of websites and apps' to Yes. This will allow the Facebook pixel to work. You can then go back and restore your settings after testing.


  • Last Modified: 16/02/2017 Neto Version: 6.6