[Resolved] Selectively Add Code to Header

Home Forums Support [Resolved] Selectively Add Code to Header

Home Forums Support Selectively Add Code to Header

  • This topic has 3 replies, 2 voices, and was last updated 6 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #536659
    Dorian

    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

    #536777
    Tom
    Lead Developer
    Lead Developer

    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 ๐Ÿ™‚

    #537482
    Dorian

    Hi Tom,

    Thanks for helping, that solved it.

    Cheers,

    Dorian

    #537536
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.