Title: Adding Google Tag specifics
Last modified: October 1, 2025

---

# Adding Google Tag specifics

 *  [morrisonfirestick](https://wordpress.org/support/users/morrisonfirestick/)
 * (@morrisonfirestick)
 * [8 months, 3 weeks ago](https://wordpress.org/support/topic/adding-google-tag-specifics/)
 * Hello. I am attempting to add the Google Tag Manager snippets of code into my
   website. I have read that to do this, simply modify the header.php file and add
   the first part of the code just below the opening head tag. No problem there.
   The issue I am having is with the second snippet. Google says to add the second
   snippet of code just before the opening body tag. I see a opening body tag in
   header.php but do not see any closing body tag. Something tells me I need to 
   add the second snippet of code to a different file. Both snippets of code need
   to run on every page per Google.
 * Please advise, thanks.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadding-google-tag-specifics%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [morrisonfirestick](https://wordpress.org/support/users/morrisonfirestick/)
 * (@morrisonfirestick)
 * [8 months, 3 weeks ago](https://wordpress.org/support/topic/adding-google-tag-specifics/#post-18664115)
 * These are the only body tags I see my header.php file:
 * >
 *     ```wp-block-code
       <body <?php body_class(); ?> <?php oceanwp_schema_markup( 'html' ); ?>><?php wp_body_open(); ?>
       ```
   
 *  [Shahin](https://wordpress.org/support/users/skalanter/)
 * (@skalanter)
 * [8 months, 3 weeks ago](https://wordpress.org/support/topic/adding-google-tag-specifics/#post-18664965)
 * Hello [@morrisonfirestick](https://wordpress.org/support/users/morrisonfirestick/),
 * Thank you for reaching out.
 * In this case, please follow the steps explained in this link:
    [https://docs.oceanwp.org/article/709-add-google-tag-code-into-header-section](https://docs.oceanwp.org/article/709-add-google-tag-code-into-header-section).
 * Also, you can search the WordPress repository to find a plugin for this: [https://wordpress.org/plugins/](https://wordpress.org/plugins/).
   Use a third-party plugin for Google Tag Manager, or find a plugin that allows
   custom code/snippets to add your code and assign it to the <head> tag.
 * I hope it helps,
    Best Regards
 *  Thread Starter [morrisonfirestick](https://wordpress.org/support/users/morrisonfirestick/)
 * (@morrisonfirestick)
 * [8 months, 3 weeks ago](https://wordpress.org/support/topic/adding-google-tag-specifics/#post-18667032)
 * Thank you for the reply. The document explains to create a child theme and then
   paste the code into the head part of the file. That would apply to the first 
   part of the snippet which Google says to paste the code there.
 * But my problem is the second snippet of code that Google says to paste right 
   after the <body> tag.Where do I paste that exactly? (Check my inquiry again on
   WordPress as I posted the actual code from my header.php file)
 *  [Shahin](https://wordpress.org/support/users/skalanter/)
 * (@skalanter)
 * [8 months, 3 weeks ago](https://wordpress.org/support/topic/adding-google-tag-specifics/#post-18667278)
 * Hello [@morrisonfirestick](https://wordpress.org/support/users/morrisonfirestick/),
 * Thank you for the update,
 * For the second Google Tag snippet (the one Google says goes right after <body
   >), with OceanWP you don’t need to edit header.php directly. Instead, you can
   use the wp_body_open() hook that is already in your header.php file.
 * Anything you want to appear immediately after the opening <body> tag can be hooked
   into wp_body_open(). Using a child theme function and if you’re comfortable with
   a bit of code, add this to your child theme’s functions.php: [https://docs.oceanwp.org/article/90-sample-child-theme](https://docs.oceanwp.org/article/90-sample-child-theme):
 *     ```
       add_action( 'wp_body_open', function() {
           // Paste your second Google Tag snippet here
       });
       ```
   
 * This ensures it runs immediately after <body> on every page without manually 
   editing theme files.
 * Hope it helps,
    Best Regards
 *  Thread Starter [morrisonfirestick](https://wordpress.org/support/users/morrisonfirestick/)
 * (@morrisonfirestick)
 * [8 months, 3 weeks ago](https://wordpress.org/support/topic/adding-google-tag-specifics/#post-18667953)
 * Thank you for the reply.
 * I tried performing your steps. I can successfully create a child theme complete
   with imported customization, and per what I’ve read, copy the header.php file
   from the ‘primary’ theme, and paste it into the child theme. From there, I modify
   the header.php in the child theme and insert the first snippet of code from Google.
   No issues at all.
 * The problem is editing the functions.php in the child theme. I insert your code
   and replace where you indicated with the snippet of Google code. The moment I
   save the changes to the functions.php file, it completely breaks my website and
   I have to perform a restore.
 * Please advise. I am copying and pasting the code correctly into the header.php
   and functions.php files.
 * Thanks.
 *  [Shahin](https://wordpress.org/support/users/skalanter/)
 * (@skalanter)
 * [8 months, 2 weeks ago](https://wordpress.org/support/topic/adding-google-tag-specifics/#post-18669189)
 * Hello [@morrisonfirestick](https://wordpress.org/support/users/morrisonfirestick/),
 * Thank you for the feedback.
 * The child theme itself isn’t causing the error, most likely the issue is with
   the code added to your child theme’s functions.php. Even a small syntax mistake(
   like a missing semicolon, quote, or bracket) can break the site completely.
 * To help troubleshoot, could you:
    Share the exact code you added to functions.
   php here. Enable WordPress debugging by adding the following to wp-config.php
   if not already done:
 *     ```
       define( 'WP_DEBUG', true );
       define( 'WP_DEBUG_LOG', true );
       define( 'WP_DEBUG_DISPLAY', false );
       ```
   
 * [https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/](https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/)
   
   Then check the debug log (wp-content/debug.log) and share any errors.
 * Once we see the code and errors, we can pinpoint exactly what’s breaking your
   site and fix it safely.
 * Hope it helps.
    Best Regards

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Adding Google Tag specifics’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/oceanwp/4.1.6/screenshot.png)
 * OceanWP
 * [Support Threads](https://wordpress.org/support/theme/oceanwp/)
 * [Active Topics](https://wordpress.org/support/theme/oceanwp/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/oceanwp/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/oceanwp/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Shahin](https://wordpress.org/support/users/skalanter/)
 * Last activity: [8 months, 2 weeks ago](https://wordpress.org/support/topic/adding-google-tag-specifics/#post-18669189)
 * Status: not resolved