• I have found several references to placing the Google analytics Tracking code after the <body> tag. This is contrary Googles instructions that the tracking code be put in just before the closing </head> tag.

    For example from http://www.wpbeginner.com/beginners-guide/how-to-install-google-analytics-in-wordpress/ :
    How to Install Google Analytics in WordPress

    There are 3 ways to install Google analytics in WordPress. Direct paste, functions.php, and plugins.

    Direct Paste Method

    Copy the code that you received in Step 4, and paste it in your theme’s header.php right after the <body> tag.

    Can anyone confirm where I should put the trackingg code? Is it OK to have it in the <head> tag as google directs?

Viewing 2 replies - 1 through 2 (of 2 total)
  • In the head is where Google Analytics by Yoast puts it, so I assume they have a very good reason for doing so.

    That said, the Google Analytics js does not change in any way how a page loads in a browser, so it could be included in the body.

    Also, since the next element after the closing head is the opening body tag, I don’t really think it matters.

    Perhaps you could ask the site referenced why they choose to do so.

    Thread Starter markf1

    (@markf1)

    Thanks for your reply and info!

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

The topic ‘Google Analytics Tracking Code’ is closed to new replies.