Google analytics to wordpress without plugin

Adding Google analytics to wordpress without plugin

There are many plugins to add Google analytics to wordpress, Google Analytics is very useful tool for any website or wordpress. There are lot’s of plugins available in wordpess to add Google analytics but when there is a simple way is available then why we use plugins, having lots of plugins in your wordpress is decrease  your blog performance I suggest only use wordpress plugins when there is no simple way is available for doing this you can maintain your blog performance. Follow steps given below to add Google analytics to wordpress without plugin.

  • Create Google analytics accounts if not created yet
  • Log in to Google analytics accounts
  • Click on the Admin page on the right side after login
  • Select a account from the dropdown list in the Account column
  • In property column click on tracking info
  • Click on the tracking code then copy the code
  • Login to your WordPress blog as admin
  • Click on Appearance then click editor
  • In editor you find header.php click on it
  • Paste your Google analytics code just before </head>
  • Save your file

 

That’s it now you can track your wordpress blog with Google analytics.

To loging or Singup in Google Analytics Click link given below for adding Google analytics to wordpress without plugin.

Google Analyitics

 

 

 

Comments

  1. says

    Hey there my buddy! I wish to express that this post is incredible, great created obtainable with approximately almost all major infos. I wish to find far more articles like this .

  2. says

    Although this is the way to add analytics without a plugin, it’s not advised to do so, as any theme update will overwrite your custom edits to the theme files. A plugin would not have your analytics lost just because the theme is updated, so no need remembering to re-add them manually, and is therefore the recommended approach.

  3. says

    It can certainly be done this way, but it is FAR from ideal. WordPress provides a lot of tools in the way of enqueueing Javascript, and making sure that everything remains as compartmentalized as possible. The way this SHOULD be done might look a little more complicated, but it ensures that everything follows the standard order of operations, as well as taking any potential naming conflicts into consideration.

    Since this is done on the server-side, more advanced users can enqueue their Javascript files on an as-needed basis rather than unnecessarily loading external assets on pages that don’t require them.

    Add the Google Analytics code into its own Javascript file and place it on your server alongside the rest of your Javascript files (usually a directory in your theme called “scripts” or “js”). Then in functions.php, add the following:

    add_action( ‘wp_enqueue_scripts’, ‘my_theme_add_scripts’ );
    function my_theme_add_scripts(){
    wp_register_script(‘google-analytics’, get_stylesheet_directory_uri() . ‘/scripts/google_analytics.js’);
    wp_enqueue_script( ‘google-analytics’ );
    }

    This will ensure that your Javascript files are added appropriately. The same logic works for enqueueing stylesheets as well.

  4. Sarah says

    Thanks Matt Maiorano and Raj for your insights.
    Does using Matt’s method prevents me from adding any code before the closing tag in my theme’s php files? Or do I still need to add something on these files ?
    (My theme is also “Iconic One Theme”)

    Thanks in advance for your help.

  5. Kojo says

    Thank you for this. First search result and I got what I needed. You’re even using the same theme as I am

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>