WordPress.org

Ready to get started?Download WordPress

Forums

Google Anlytics; hardcoding or using a plugin? (4 posts)

  1. About.blank
    Member
    Posted 7 months ago #

    Hello WordPress.org Community,

    I'm new to WP and still exploring and learning many of its aspect.

    I run a (very) small blog that I want to monitor using GA (unless there is another recommendation). I pretty much know how to connect the blog to GA, but I have one question that I hoped that you could help me with: should I hardcode the GA ID into the theme or should I use a plugin?

    Basically, whenever it makes sense I usually prefer to hardcode or edit the WP/Theme files over using plugins to achieve the required functionality. I learn a lot from it, and although I might be wrong, I assume that it reduces the security risk and the overall dependability on the plugin's continued maintenance.
    When it comes to GA I'm not so sure how to go about it. I assume that a plugin adds the GA ID even when switching themes (I'm still experimenting with the look and feel so I'm going back between themes now and again), while in the manual approach I would need to remember to add it with each theme change.
    I would appreciate any recommendation.

    Also, in case I will hard code it, where should I insert the code into? The header.php or the footer.php (I read mixed opinions)?

    Thank you

  2. shadez
    Member
    Posted 7 months ago #

    in my opinion, less plugins = less headache. put it in header.php - just before wp_head() gets called.

  3. hiphopinenglish
    Member
    Posted 7 months ago #

    Some web hosting companies offer Analytics at domain level, so it's worth checking with your host in regards to that option.

  4. About.blank
    Member
    Posted 7 months ago #

    Thank you.

    @hiphopinenglish
    I will check with my host, thank you for pointing this out.

    @shadez
    I tend to agree with your approach :). Thank you for indicating where the code should go.

Reply

You must log in to post.

About this Topic