Put Google Analytics Experiment Code In Header of Just Home Page

Community Forums Forums Design Tips and Tricks Put Google Analytics Experiment Code In Header of Just Home Page

This topic is: not resolved

This topic contains 2 replies, has 3 voices, and was last updated by  mborger 1 year, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5644

    JetAviator7
    Participant
    Post count: 5

    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

    #7029

    nickthegeek
    Keymaster
    Post count: 751

    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

    #39015

    mborger
    Participant
    Post count: 109

    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

     

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.