Adding of Google Analytics code to my WP site

6 replies
Hello,

I would like to add the Google Analytics code to my WP site, namely the homepage, but I am not sure where/how to add it. You see, I have a few domains registered on my cpanel and when I access that site's file (public_html....), I am at a loss as to which file to locate to add the code.

Any assistance would be appreciated, as I would like to add it ASAP, thanks.

Sincerely,

DK
#adding #analytics #code #google #site
  • Profile picture of the author m4rx
    You actually don't need to use the files.

    Login to wordpress and go to the templates section.

    Edit the current template that you are using, and you can add it in.

    If you are just looking to add it to a sidebar area, you can download the Text Widget

    Text*Widget — Support — WordPress.com

    and you can just paste in your adsense code to there.

    Any more questions?

    If you are trying to just put them in your sidebar, you should do that. For the most part, if you feel like editing the files, you only need to do the templates, which are located at public_html/wp-content/themes.

    If you have different domains, they should be stored in their own separate directories, with your main domain routing to /public_html.

    Any more questions?

    -Tyler
    Signature
    We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle
    Bored. Learn everything you need to know about Organic Gardening.
    {{ DiscussionBoard.errors[4620921].message }}
    • Profile picture of the author DoraKong
      Hello,

      Many thanks for the prompt and detailed reply, much appreciated.

      I logged into my WP Dashboard and accessed the themes>templates section, but I am still a bit confused, since I want to add the code to the homepage of the site, do I add it to header.php or index.php? The code has to be immediately before the closing </head> tag, so I think it might be header.php, but just wanted to get some clarifications first, thanks!

      DK
      Signature
      My Traffic Titan-Sign up for FREE traffic with 19.5% Click-Through and 29.17% Conversion Rates!
      {{ DiscussionBoard.errors[4621000].message }}
      • Profile picture of the author m4rx
        Yes, sorry I guess I could have been clearer.

        You will need to edit the header.php file, but make sure that you do not edit any of the php.

        Do you only want it to show on the homepage? or do you want it to show on every one of your pages?

        If you want it to show on every page, just open header.php and find the </head> tag. Most likely just the bottom of the file depending on the template.

        -Tyler
        Signature
        We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle
        Bored. Learn everything you need to know about Organic Gardening.
        {{ DiscussionBoard.errors[4623885].message }}
  • Profile picture of the author johnnyN
    normally you would want analytics on every page of your website.
    the easiest way is to install a wordpress plugin to do this.
    I normally use analyticator plugin, but there are many others.
    {{ DiscussionBoard.errors[4626780].message }}
    • Profile picture of the author m4rx
      Yeah. I normally use StatPress and have never really had any problems with it.

      I would try it out if it is for a personal site, or a site that you update often.

      If you have multiples that you are tracking, I guess you could use GAnalytics -_-

      But its more of a preferential thing.

      Analyticator is nice too.

      -Tyler
      Signature
      We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle
      Bored. Learn everything you need to know about Organic Gardening.
      {{ DiscussionBoard.errors[4628013].message }}
  • Profile picture of the author Spastabetic
    There's a difference between analytics and webmaster tools. The former really want to be on every page, a free plugin will do the job as suggested above. The webmaster verification code just needs putting in the head section so you can edit the header.php of your current them.

    Believe you only need do this once per site, could be wrong though.
    {{ DiscussionBoard.errors[4628169].message }}

Trending Topics