• 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

Puttin FB Tracking Pixel On Home Page Only

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 › Puttin FB Tracking Pixel On Home Page Only

This topic is: resolved

Tagged: fb tracking code

  • This topic has 2 replies, 2 voices, and was last updated 8 years, 10 months ago by ATS.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • August 1, 2014 at 2:59 am #116544
    ATS
    Participant

    Dear colleagues,

    getting exhausted finding the solution here, need your help.

    FB Tracking Code needs to be on Home page only here http://www.highspeedlowdrag.org (using Minimum 1,0 theme)

    I use Simple Hooks and put into wp_head Hook area this code:

    <?php
    if(is_home()) { ?>
        <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;
      }
      _fbq.push(['addPixelId', '1453822068210779']);
    })();
    window._fbq = window._fbq || [];
    window._fbq.push(['track', 'PixelInitialized', {}]);
    </script>
    <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=1453822068210779&ev=NoScript" /></noscript>
    
    <?php }
    ?>

    I also tried if(is_frontpage()) and if(is_front_page()) but in both cases it presents the above code on ALL pages and posts.
    Can anyone advise on how to feature that in Home page's code only?
    Thank you!

    http://www.highspeedlowdrag.org
    August 2, 2014 at 4:08 am #116650
    Brad Dalton
    Participant

    Should placed into a .js file and then loaded conditionally. Here's an example http://wpsites.net/tools/how-to-install-buysell-ads-bsa-code-manually-in-any-theme/


    Tutorials for StudioPress Themes & WooCommerce.

    August 10, 2014 at 11:36 pm #118138
    ATS
    Participant

    Thank you, braddalton

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Puttin FB Tracking Pixel On Home Page Only’ is closed to new 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