Reputation: 41
I add the following to my header.php of WordPress theme
<?php if(is_front_page()){ ?>
----google analytics experiment code---
<?php } ?>
But doesn't work, do you have any suggestion?
Thank
Upvotes: 1
Views: 127
Reputation: 136
Try to create a PHP if-else statement based on $_SERVER['REQUEST_URI']
to match the home page. Code you posted is working for me.
OR try is_home()
is WordPress version old ?
Upvotes: 0
Reputation: 1738
You can inject this code higher into your WordPress header using a WordPress hook with a high priority in your themes functions.php file. Google Experiment Code
function google_experiment_code() {
?>
// Google Analytics Content Experiment code -->
<?php
}
add_action( 'wp_head','google_experiment_code', 5 );
Finally the action wp_head will run this function with a priority of 5
. you could run it even higher by using a lower number.
Upvotes: 1