More

    Where is the best place to insert the google analytics code in WordPress?

    Every site needs to track traffic, therefore Google Analytics is here. Our question is, where is the best place to insert google analytics code especially in WordPress? Is the best place header or footer?

    Google recommendations:

    Paste it into your web page, just before the closing </head> tag.

    One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. It is customary to place JavaScript code in the <head> section, and we recommend placing the snippet at the bottom of the <head> section for best performance

    Google recommend to putting your Google Analytics code in WordPress just before the closing </head> tag and this is the best place. Edit the header.php in /wp-content/themes/your_theme/ and put the code into.

    The code in <head> will add a little latency but Google Analytics code in the footer will reduce the number of pageviews recorded at some small margin.

    Bonus:

    To adding your Google Analytics code in the <head> also comes with the added benefit of being able to verify Google Search Console without any other manual verification methods.

    Recent Articles

    How to remove category & tag base from WordPress URL

    Would you like to remove the category & tag base from WordPress URL? Do you need custom URL's? It's a super simple!...

    How to Disable Right Click on WordPress

    Are you worried about having your images stolen from your WordPress website? Then you need to know how to disable right click on...

    How to redirect HTTP to HTTPs in .htaccess

    Today's standard is to have an https certificate. Google will love you if your sites are secured. So https is not standard,...

    How to fix TypeError: $ is not a function in WordPress

    We can guess. You purchased a theme or plugin and a console shown a message "TypeError: $ is not a function"? Ok,...

    How to fix Unknown collation: ‘utf8mb4_unicode_520_ci’

    Unknown collation is probably caused because your local and live server are running different versions of MySQL. This problem mostly comes when...

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Stay on op - Get the daily news in your inbox