Google Site Tag

I need to place a javascript on a very specific page’s head. Where would I do that?

Hello @treytaulbee,

Thanks for writing in!

Most of the time if there is a need to insert a code in the header or footer, we recommend to install “Insert Headers and Footers” plugin (https://wordpress.org/plugins/insert-headers-and-footers/). This plugin will allow you to easily manage any script you may need to add for the header or the footer. This plugin may not apply if the script or code added is for specific pages.

To resolve your issue, I would recommend that you install a child theme. What you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released.

Once the child theme is set up, please add the following code in your child theme’s functions.php file

function add_header_script(){ 
  if ( is_page(123) ) : ?>

  <p>Add your Google Site Tag code here</p>

<?php endif;
}
add_action('wp_head', 'add_header_script');

Please noticed that I have a condition is_page(123) where in 123 is the page ID where you want the code to insert. To know more how you can get the page ID, please check this out: https://theme.co/apex/forum/t/setup-how-to-locate-post-ids/59

Please let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.