Archived topic
Selectively Add Code to Header
3 replies · Started by Dorian on March 30, 2018
Hey guys,
I need to use Google Analytics' experiment feature.
I set up the experiment in Analytics, and it requires me to insert code in the head of one of the pages only.
How do I insert that code into the head of just home page?
Thanks,
Dorian
You could do this in the wp_head hook in GP Hooks.
1. Get the slug of your page, it's this part: mywesbite.com/my-page
2. Do this in the hook:
<?php if ( is_page( 'my-page' ) ) : ?>
Your code in here.
<?php endif; ?>
Hope this helps :)
Hi Tom,
Thanks for helping, that solved it.
Cheers,
Dorian
You're welcome :)