• 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

Put Google Analytics Experiment Code In Header of Just Home Page

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 › Design Tips and Tricks › Put Google Analytics Experiment Code In Header of Just Home Page

This topic is: not resolved

Tagged: google analytics

  • This topic has 2 replies, 3 voices, and was last updated 12 years, 11 months ago by mborger.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • December 16, 2012 at 7:48 pm #5644
    JetAviator7
    Member

    I am trying to use Google Analytic s to split test my Home Page against a test page but if I put the code in the Genesis wp-head box then the code is in the header of every page.

    How do I put the code in the header of just the Home page so that it is not in the header of all of the other pages?

    Thanks,

     

    John

    December 22, 2012 at 2:25 pm #7029
    nickthegeek
    Member

    Try using the Genesis Simple Hooks plugin and the wp_head or genesis_meta hook. Then make the code conditional for is_home()
    http://nickc.co/conditional-content

    May 2, 2013 at 7:59 pm #39015
    mborger
    Member

    Hi Nick. I'm not sure if this the right place, but I have a similar concern. I'm trying to get Google Experiments to validate on a Premise page. When I try to validate on the GCE page, it says "No experiment code found" with a bubble saying the validation code needs to be in the first 256kb (not sure if that's the issue).

    I do have the checkbox on the landing page checked to enable GCE and have the proper code in the Original page.

    I thought I'd try another way and put the GCE experiment code in the page header. Using GSH, I put this code in the genesis_meta Hook where 5804 if the landing page ID (the GCE script is just copied from the Experiment page):

    <!-- Google Analytics Content Experiment code -->
    <?php
    if(is_page(5804)) { ?>
    <script>function utmx_section(){}function utmx(){}(function(){var
    k='40228853-3',d=document,l=d.location,c=d.cookie;
    if(l.search.indexOf('utm_expid='+k)>0)return;
    function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.
    indexOf(';',i);return escape(c.substring(i+n.length+1,j<0?c.
    length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write(
    '<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':
    '://www')+'.google-analytics.com/ga_exp.js?'+'utmxkey='+k+
    '&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().
    valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
    '" type="text/javascript" charset="utf-8"><\/sc'+'ript>')})();
    </script><script>utmx('url','A/B');</script>
    <?php }
    ?>
    <!-- End of Google Analytics Content Experiment code -->

    GCE still won't validate saying it can't find the code. What else can I try?

    Thanks,
    Mike

     

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ 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

© 2026 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