Announcement

Collapse
No announcement yet.

Facebook Pixel Code

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Facebook Pixel Code

    This is what I am adding for comment or correction or for you to use:

    Code:
    <!-- 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', '12345678123456678');
    fbq('track', 'PageView');
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PageTitle%22%20%2f%3e%20%3d%3d%20%22Newsletter%20Sign%20Up%22" >
    	fbq('track', 'CompleteRegistration');
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsBrochureHomePage%22%20%2f%3e">
    	fbq('track', 'ViewContent');
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Product%20Page%22" >
    	fbq('track', 'ViewContent');
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Search%20Results%22">
    	fbq('track', 'Search');
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Add%20To%20Cart%20Confirmation%22" >
    	fbq('track', 'AddToCart');
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Checkout%20Page%200%22" >
    	fbq('track', 'InitiateCheckout');
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Checkout%20Page%202%22">
    	fbq('track', 'AddPaymentInfo');
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Receipt%22" >
    	fbq('track', 'Purchase', {value: '<actinic:variable encoding="perl" name="Total" selectable="false" />', currency: 'GBP'});
    </actinic:block>
    </script>
    <noscript>
    <img height="1" width="1"
    src="https://www.facebook.com/tr?id=1234567812345678&ev=PageView
    &noscript=1"/>
    </noscript>
    <!-- End Facebook Pixel Code -->
    I have also put the same code with the ViewContent tag in the Wordpress Header when sites have associated blogs:

    Code:
    <!-- 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', '1234567812345678');
    fbq('track', 'PageView');
    fbq('track', 'ViewContent');
    </script>
    <noscript>
    <img height="1" width="1"
    src="https://www.facebook.com/tr?id=1234567812345678&ev=PageView
    &noscript=1"/>
    </noscript>
    <!-- End Facebook Pixel Code -->
    Thank you.
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

  • #2
    Problem with 'Total'

    I have a problem with the above code and I would be grateful for some help.

    The line:

    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Receipt%22" >
    	fbq('track', 'Purchase', {value: '<actinic:variable encoding="perl" name="Total" selectable="false" />', currency: 'GBP'});
    </actinic:block>
    Is generating errors on the Pixel validation page: I is producing the value:

    Code:
    {"value":"NETQUOTEVAR:TOTAL","currency":"GBP"}
    Rather than a numeric figure for the Cart/Order Total. Is there a 'Raw' variable that can be used here istead of <actinic:variable encoding="perl" name="Total" selectable="false" />

    Or should the encoding be something else?

    Or should it be wrapped in <Actinic:XMLTEMPLATE NAME="ShoppingCart"> tags???

    Thank you
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    Comment


    • #3
      Hi Jonathan,

      Did you ever make any progress with this? Just setting up our pixel now & had a Google first.

      If I get any joy - I'll feed back here.
      Matt. M - SMR Enterprises Ltd.

      Comment


      • #4
        It was the uneccessary additions to the variable:
        Code:
        <actinic:variable encoding="perl" name="Total" selectable="false" />
        It just needs to be this:

        Code:
        <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Receipt%22" >
        	fbq('track', 'Purchase', {value: '<actinic:variable name="Total" />', currency: 'GBP'});
        </actinic:block>
        However I had a similar issue with Trustpilot integration and the wonderful Norman wrote this:

        Code:
        <!-- Trustpilot conversion script -->
        <script type="text/javascript">
        // SellerDeck tweaks start
        // SellerDeck amount may have  sign and thousand commas
        function getcartamount(){
        	return ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '');
        }
        
        // we've added a cartqtyfield class-name to the Qty field in the checkout
        function getcarttotalitems(){
        	var basket_size = 0;
        	$( ".cartqtyfield" ).each(function(){
        		var itemcount = $(this).text();
        		if ( ! isNaN(itemcount) )
        			{
        			basket_size += itemcount - 0;
        			}
        		});
        	return basket_size;
        }
        // SellerDeck tweaks end
        
        // TP code continues
        (function(c,o,n,v,e,r,t){c['TPConversionObject']=e;c[e]=c[e]||function(){c[e].buid='xxxxxxxxxxxxxxxxxxxxxxxx',(c[e].q=c[e].q||[]).push(arguments)};r=o.createElement(n),t=o.getElementsByTagName(n)[0];r.async=1;r.src=v;t.parentNode.insertBefore(r,t)})(window,document,'script','https://widget.trustpilot.com/conversion/conversion.js','tpConversion');
        
        tpConversion('amount', getcartamount()); // total cost of the order, eg. '13.00'
        tpConversion('currency', 'GBP'); // your shop's currency, e.g. USD
        tpConversion('basket_size', getcarttotalitems()); // total number of items purchased
        </script>
        <!-- End Trustpilot conversion script -->
        In fact you chimed in on the thread!

        Code:
        http://community.sellerdeck.com/showthread.php?t=57476
        Best wishes!
        Jonathan Chappell
        Website Designer
        SellerDeck Website Designer
        Actinic to SellerDeck upgrades
        Graphicz Limited - www.graphicz.co.uk

        Comment


        • #5
          What a gentleman - thank you.

          You simply dropped this in during the HTML header?
          Matt. M - SMR Enterprises Ltd.

          Comment


          • #6
            Note that <Actinic:Variable Name="Total"/>

            May return text like 12,345.67 and your external code may expect just

            12345.67 so that's what the:
            Code:
            ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '')
            does.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


            • #7
              Originally posted by NormanRouxel View Post
              Note that <Actinic:Variable Name="Total"/>

              May return text like 12,345.67 and your external code may expect just

              12345.67 so that's what the:
              Code:
              ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '')
              does.
              Thanks Norman,

              I believe that FB are able to interpret the currency literally, as they have asked specifically what currency and format is being used - I'll let you know once I've tested.
              Matt. M - SMR Enterprises Ltd.

              Comment


              • #8
                Thank you Norman!

                Yes Matt, bottom of Javascript Header Functions, then it will be on all pages including receipt wihich has a different outer layout.
                Jonathan Chappell
                Website Designer
                SellerDeck Website Designer
                Actinic to SellerDeck upgrades
                Graphicz Limited - www.graphicz.co.uk

                Comment


                • #9
                  I am not very good at javascript.
                  Would something like this work?
                  Code:
                  var carttotal = ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '');
                  	fbq('track', 'Purchase', {value: 'document.write(carttotal)', currency: 'GBP'});
                  Jonathan Chappell
                  Website Designer
                  SellerDeck Website Designer
                  Actinic to SellerDeck upgrades
                  Graphicz Limited - www.graphicz.co.uk

                  Comment


                  • #10
                    Just
                    Code:
                    	fbq('track', 'Purchase', {value: ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, ''), currency: 'GBP'});
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                    • #11
                      Thank you so much.
                      Jonathan Chappell
                      Website Designer
                      SellerDeck Website Designer
                      Actinic to SellerDeck upgrades
                      Graphicz Limited - www.graphicz.co.uk

                      Comment


                      • #12
                        Using Chrome's Pixel helper that shows the price as NETQUOTEVAR:

                        Code:
                        EVENT INFO
                        URL Called: Show
                        Load Time: 13.33 ms
                        Pixel Code: Hide
                        fbq('track', 'Purchase', {value: ('NETQUOTEVAR:TOTAL')
                        Pixel Location: Show
                        Frame: Window
                        Jonathan Chappell
                        Website Designer
                        SellerDeck Website Designer
                        Actinic to SellerDeck upgrades
                        Graphicz Limited - www.graphicz.co.uk

                        Comment


                        • #13
                          Hi Jonathan,

                          Every event but the purchase fired successfully overnight - as I can see you're battling this too!

                          I'll be doing some work on this on our development server later, if I reach a solution I'll let you know.

                          I'm inclined to look at the GA integration as that captures transaction values successfully.
                          Matt. M - SMR Enterprises Ltd.

                          Comment


                          • #14
                            The field I use for GA conversion value is as follows:

                            var google_conversion_value = NETQUOTEVAR:ORDERTOTALBASEUNIT;

                            Wondering if it's possible to bring this inline.
                            Matt. M - SMR Enterprises Ltd.

                            Comment


                            • #15
                              Hi Matt,

                              A small v18 teaser - Facebook Pixel event tracking will be natively available within the software. But I bet there's a way to get it working as you're doing now!

                              Cheers,
                              Justin
                              Ops Manager, Sellerdeck

                              Comment

                              Working...
                              X