I’m following this tutorial on adding Google Content Experiments code to header.php.

I added the following code to header.php:

<?php if (is_page('346') ):?>
    <!-- Google Analytics Content Experiment code -->
        ...
    <!-- End of Google Analytics Content Experiment code -->
<?php endif; ?>

This didn’t produce the content experiment code on the front end. I tried:

<?php if (is_page(346) ):?>
    <!-- Google Analytics Content Experiment code -->
        ...
    <!-- End of Google Analytics Content Experiment code -->
<?php endif; ?>

This didn’t work either.

Can you see why this code is not working? Thanks.

8 s
8

you can use this for

<?php 
global $post;

if( $post->ID == 346) { ?>

      <!-- do your stuff here -->

<?php } ?>

you can use this anywhere either in header or anywhere else.

Leave a Reply

Your email address will not be published. Required fields are marked *