Adding Facebook lead event pixel to WordPress thank-you page

3 replies
Hi, guys!

How can I add the attribute fbq('track', 'Lead'); only on the thank-you pages on a WordPress site?

It's easy to add the main Facebook pixel on all the pages of a WordPress site via a header plugin. But how would you do this for individual pages?

Thanks!
#adding #event #facebook #lead #page #pixel #thankyou #wordpress
  • Profile picture of the author netqom
    You can according to it. Initializing a second pixel calling fbq('addPixelId', '0123456789'); right after fbq('init', '9876543210');
    <script>
    !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=f unction(){n.callMethod?
    n.callMethod.apply(n,arguments):n.queue.push(argum ents)};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', 'Pixel_ID_1');
    fbq('addPixelId', 'Pixel_ID_2');
    fbq('track', "PageView");
    fbq('track', 'Purchase', {value: '{ { subtotal_price | money_without_currency } }',currency: '{ { shop.currency } }'});

    </script>
    <noscript>
    <img height="1" width="1" style="display:none"
    src="https://www.facebook.com/tr?id=Pixel_ID_1&ev=PageView&noscript=1"
    />
    <img height="1" width="1" style="display:none"
    src="https://www.facebook.com/tr?id=Pixel_ID_2&ev=PageView&noscript=1"
    />


    This code can do your help.
    {{ DiscussionBoard.errors[11021958].message }}
    • Profile picture of the author perneali45
      Originally Posted by netqom View Post

      You can according to it. Initializing a second pixel calling fbq('addPixelId', '0123456789'); right after fbq('init', '9876543210');
      <script>
      !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=f unction(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(argum ents)};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', 'Pixel_ID_1');
      fbq('addPixelId', 'Pixel_ID_2');
      fbq('track', "PageView");
      fbq('track', 'Purchase', {value: '{ { subtotal_price | money_without_currency } }',currency: '{ { shop.currency } }'});

      </script>
      <noscript>
      <img height="1" width="1" style="display:none"
      src="https://www.facebook.com/tr?id=Pixel_ID_1&ev=PageView&noscript=1"
      />
      <img height="1" width="1" style="display:none"
      src="https://www.facebook.com/tr?id=Pixel_ID_2&ev=PageView&noscript=1"
      />


      This code can do your help.
      I know the code to ad. My question was how can I do it for specific posts and pages.

      I think the code needs to go after the closing </head> tag.

      But how can this be done for individual pages?

      If I edit the theme, then even the landing pages themselves will show the pixel which will result in showing "100% conversions" (which is wrong).

      And I can't add the pixel inside the content area of the post or page, because I don't think it will work.

      Thanks!
      {{ DiscussionBoard.errors[11022177].message }}
      • Profile picture of the author netqom
        The Facebook pixel is a JavaScript or image tag that you can copy and paste onto your website's pages.

        If you do not have access to either the source code for your website or your tag management solutions,

        Go to Facebook Ads Manager | Pixels
        Click Create a Pixel
        Click Install Pixel Now or Email Pixel Code.
        Add the code to your website pages before the ending </head> tag in the page's HTML:


        <!-- Facebook Pixel Code -->
        <script>
        !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=f unction(){n.callMethod?
        n.callMethod.apply(n,arguments):n.queue.push(argum ents)};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');
        // Insert Your Facebook Pixel ID below.
        fbq('init', 'FB_PIXEL_ID');
        fbq('track', 'PageView');
        </script>
        <!-- Insert Your Facebook Pixel ID below. -->
        <noscript><img height="1" width="1" style="display:none"
        src="https://www.facebook.com/tr?id=FB_PIXEL_ID&amp;ev=PageView&amp;noscript=1"
        /></noscript>
        <!-- End Facebook Pixel Code -->


        It can work for every post and pages. Please check and let me know.

        Thank you
        {{ DiscussionBoard.errors[11022663].message }}

Trending Topics