Help with adding code into the <HEAD> of pages and every web page please!

Hi, I haven’t had much experience of doing this, so I’m hoping you’ll be able to help me out and point me in the right direction of the adding some code into the of pages - an SEO specialist has suggested adding various code and some I’m unsure of where it’s supposed to go! I’ve been told I need to add in the code and not use plugins!

  1. Google Analytics
    Copy and paste code as the first item into the of every webpage you want to track. If you already have a Global Site Tag on your page, simply add the config line from the snippet to your existing Global Site Tag.
  • I don’t know how to add the code to every webpage! Do I just do this in the Theme Editor > functions.php I’m not too sure if I need to add any specific code to make sure it’s added to the and is applied to every page.
  1. Google Tag Manager
    Paste the code as high in the of the page as possible.
  • I didn’t realise there was a hierarchy! To do this, do I simply add the code in above the Google Analytics code?

Thanks!

Hi @core365,

We have a plugin to add the Google Analytics but I am not sure if it will be suitable for your use case as you might have a special code. You can read more about our plugin here.

If you want to add code into the head of the whole website, you need to install the Child Theme first. Then you need to add the code below to functions.php file of your Child Theme:

function third_party_tracking_code() { ?>

    // Third party tracking code.

<?php }

add_action( 'wp_head', 'third_party_tracking_code' );

Replace // Third party tracking code. with whatever code you have at hand.

It will be a good idea that you read more about the functionality here.

Thank you.

Hi @christopher,

That’s great, thank you for your help and explanation!

Cheers!

You’re welcome. :slight_smile:

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