Final Step:How and Where to Add this GTag Code on WordPress Site:

Copy this gtag code and put it under <head> tag of your site.

<!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=G-NE267K4Z50"></script><script>  window.dataLayer = window.dataLayer || [];  function gtag(){dataLayer.push(arguments);}  gtag('js', new Date());  gtag('config', 'G-NE267K4Z50');</script>


To add Ggtag code to a WordPress site under <Head>tag

There are several ways add Gtag code, but, I am going to tell you a most recommended method is, through the plugin

Go to WordPress Dashboard and click plugin>>New Plugin



This is one of the suitable plugins to add Gtag code

Then, click to install and activate it.

Now it is under settings in your WordPress dashboard


Then, Click the Insert Headers and Footers to add the Gtag Code.

Now, copy the code from the google analytics code area then, paste it "Scripts in Header"



And then, click Save. Now it is OK.

By this method, no problem, if you change your WordPress theme or update it. The Gtag Code is fixed.

Then, you can visit your google analytics tool to view visitors. For that, you can view your site same device with a different browser or a separate device. You can see the results.

WOW! visitors can see through google analytics on my site.

I think you can understand my tutorial. If not clear, please comment below, I will help you. As well as if you can't see visitor yet, please comment. I do my best to help you.

Thank you and Good Luck

I think this will help you



Join the Discussion
Write something…
Recent messages
rodchristina Premium
This was so helpful and easy to follow! Thanks
Reply
Dianesmith2 Premium Plus
This tutorial was easy to follow. I will get back to you. I keep getting a message to connect to monster insights. I have an analytics account already set up but google can't see to find my g mail account. I don't understand this. Code was supposedly pasted at the head of my website already by site support.

I am getting message to connect Exact Metrics. Which of these should be connected and if so I get an error for this to.

Thank you,
Diane
Reply
Nina64 Premium
Thank you so so much! I went through all your steps that were easy to follow and then set up monster analytics. This was so much easier than all the tutorials. I can't thank you enough!!!!
Reply
Triblu Premium
Hey Sam,

Thanks for offering this training, as it is badly neeeded.

The only problem with placing tracking code in the header.php of a website's WordPress theme is that the next time the theme is updated, the tracking code will be overwritten and disappear from the website.

The users need to use an SEO plugin or... at the very least, the headers and footers plugin like that which is shown here: Feel free to update your training to include this information, as I'm sure others will be glad for the additional info.

Hope this helps you.
Reply
AmazeCPS Premium
OK. sure I will modify the training to add Gtag code
Thanks
Reply
DianeScorpio Premium
Hi - your suggested method of using the Theme Editor is not recommended. Should you ever change your theme, then Analytics will disconnect. You would have to reconnect it and will lose all the previous data related to your website.
Reply
AmazeCPS Premium
OK sure. I will modify the way of adding Gtag code.

I appreciate your comment to mention it.
Thank you.
Reply
Top