Facebook tracking pixel

Posted · Add Comment

Scheduler Forums BirchPress Scheduler Facebook tracking pixel

This topic contains 0 replies, has 1 voice, and was last updated by  Stew’s Self Service Garage 7 years, 2 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #27517

    Hi,

    Firstly, with Facebook’s recent change in tracking pixel, it’s peeked my curiosity into using them further. I currently have made a “thank you page” that you are redirected to after successfully making an appointment with the Facebook pixel in it. Facebook’s ‘purchase’ pixel allows the purchase data to be transmitted back to Facebook so you know what your conversion value is, which is very important for marketing. I currently have this set as 0 USD since each appointment could be valued at anywhere from $15 to $400, and I don’t want to set it as my average appointment value. After doing some research into this, you can dynamically send Facebook the value, and many have determined how to do this with woocommerce. I want to do something similar, but with Birchpress. I’m not asking for birchpress to do this for me, I just need to know where to pull some data from, and what this data might be identified as.

    So here is the facebook tracking code for purchase:

    <script>
    fbq('track', 'Purchase', {
    value: 247.35,
    currency: 'USD'
    });
    </script>
    

    And this is some php script a user has created to dynamically add the value:

    // FB Pixel Tracking Code
    add_action( 'woocommerce_thankyou', 'fb_pixeltracking' );
    
    function fb_pixeltracking( $order_id ) {
       $order = new WC_Order( $order_id );
       $order_total = $order->get_total();
     ?>
    <!-- Start FB Tracking - Replace XXXXXXXXXXXXXX with your tracking ID to track orders with values-->
     
        <!-- Facebook Conversion Code for Sales from Facebook Ads -->
        <script>(function() {
         var _fbq = window._fbq || (window._fbq = []);
         if (!_fbq.loaded) {
           var fbds = document.createElement('script');
           fbds.async = true;
           fbds.src = '//connect.facebook.net/en_US/fbds.js';
           var s = document.getElementsByTagName('script')[0];
           s.parentNode.insertBefore(fbds, s);
           _fbq.loaded = true;
         }
        })();
        window._fbq = window._fbq || [];
        window._fbq.push(['track', 'XXXXXXXXXXXXXX', {'value':'<?php echo $order_total ?>','currency':'GBP'}]);
        </script>
        <noscript>
        <img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/trev=XXXXXXXXXXXXXX&cd[value]=<?php echo $order_total ?>&cd[currency]=GBP&noscript=1" />
        </noscript>
         <!-- END FB Tracking -->
      
    <?php
    }

    What I’m curious to know is since you can input price for each service on birchpress, can this data be pulled by a php function similar to this? If so, where can I find the price id to get a script similar to this to work? Once again, I’m not asking for birchpress to do this for me, I just want to get some direction here.

    TL;DR
    I want to pull service price from birchpress scheduled appointments, and put it into the value section of my facebook conversion pixel.

    Thank you for your time!

Viewing 1 post (of 1 total)

The forum ‘BirchPress Scheduler’ is closed to new topics and replies.

Comments are closed.