• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Facebook Pixel Event Tracking

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Facebook Pixel Event Tracking

This topic is: not resolved

Tagged: Facebook pixel

  • This topic has 1 reply, 2 voices, and was last updated 5 years, 5 months ago by Victor Font.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • August 15, 2017 at 10:18 pm #210432
    Kiwi Brandon
    Participant

    Hi there,

    I have added the Facebook Pixel code to Genesis theme settings as a header script.

    I now need to install a modified version of that code to a specific page to track conversions, as per Facebook instructions here: https://web.facebook.com/business/help/402791146561655

    I can add this in the scripts section of the relevant page, but then I would have two Facebook Pixel Code blocks, one with the additional Event Tracking section and one without.

    Is there any way to have just one modified Facebook Pixel Code block displaying on that page?

    Many thanks!

    https://www.driveline.co.nz
    August 16, 2017 at 5:22 am #210444
    Victor Font
    Moderator

    There is, but it requires using a WordPress/PHP conditional to determine what page you are on to serve the correct code. You have to add the code to functions.php. The Genesis/Theme Settings/Header scripts area doesn't allow for PHP execution. Any PHP added to that area will be displayed as literal strings in the rendered source code. The code you would add to functions.php would look something like this:

    add_action('wp_head', 'my_facebook_tracking_pixels');
    function my_facebook_tracking_pixels() {
    
        if( is_page( 'xx' ) ) {
            ?>
            /* add specific script here */
            <script>
                
                
            </script>
        <?php
        } else {
        ?>
            /* add general script here */
            <script>
                
            </script>
        <?php
        }
    }

    Change the 'xx' parameter for is_page() to the ID of the page you want the specific tracking code on. Be very careful doing this and do not edit functions.php through the WordPress editor. If you make a mistake, your site will come down. Always edit functions.php with a text editor through FTP.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble