Now that we have the Google Analytics Code, we need to insert it in its new home.

To do this, we first must locate the header.php file. Placing the code in this file ensures that the Google Analytics Code is effective in all WordPress pages on your website.

Open the Dashboard of your WordPress website and go to Appearance and click on the Theme Editor in the submenu.

Once the Theme Editor is open, locate the Header File (header.php) from the list of WordPress files shown on the right of your Dashboard:

The Theme Editor will open and display the Theme Header PHP code held in the header.php file.


With the header.php file open, we can move on to inserting the analytics code in the correct place in the header…



Join the Discussion
Write something…
Recent messages
FKelso Premium Plus
Paul, it looks like Trish has you covered, but I have an unrelated question. Is that your logo? Did you design it? It is very clever -- I really like it.
Reply
PaulREvans57 Premium
Yes, Fran. I found someone on Fiverr to design it for me.

(Baby) Boomer Affiliate - Cash in Rocking Chair!
Reply
Triblu Premium
Hey Paul,

There is a reason that this is NOT really sound advice.

Reason is that once you add your Google tracking to the header.php file of your theme, the next time you update your theme... POOF!... your Google tracking will be gone... overwritten by the new header.php file that your theme will install for you.

So, using this technique... you would need to reinstall your Google tracking code EVERY time you update your theme.
Reply
PaulREvans57 Premium
Hi Trish,

I did mention that in training.

I only advise it for those who want to do it. I am not recommending it.

For those techie types. It is a perfectly acceptable way to get around the problem of too many plugins.

I have done this myself in the past. I am sure I will do it again in the future.

1. Create a Child Theme,
2. Activate the child theme,
3. Implement the code to the child theme,
4. When an update to the parent theme arrives, check to see if the header.php has been amended,
5. Replace/modify header.php in the child.

I only recommend this for people who are comfortable in doing this back-end stuff.
Reply
Triblu Premium
Yes Paul... adding a child theme would be the only logical way around having to install your Google tracking code with each update of your theme.
Reply
PaulREvans57 Premium
I do appreciate your wisdom, Trish.

I recommend to anyone wanting to try this process to think hard about it.

The best solution is to stick with Kyle and Carson's choice, which is the All-In-One SEO plugin.

If you feel you must go down this manual analytics tracking process, then probably you have a bigger issue with your website.
Reply
Top