Get a FREE e-course "Make Money Blogging". Learn:

           
  • How to start a blog: Keyword research, installing WordPress, themes & plugins
  • How to get more traffic to your blog
  • How to make more money from your blog
  • Tips, tricks and step-by-step instructions that even a 10 year old can follow!
Completely FREE. Also get access to my newsletter. Absolutely no spam, guaranteed.

Name:

Email:


Genesis Theme: How to Insert JavaScript Code in Your Blog

How to Insert JavaScript Code in Your WordPress Blog

How to Insert JavaScript Code in Your WordPress Blog

There are many occasions when you need to add some sort of JavaScript code into your blog.

It can be for a traffic analytics service like Google Analytics, or for the analytcis for a newsletter service provider like Aweber.

Whatever the reason, the fact remains that inserting this code properly is very important in order to collect the right data.

 

The Requirement

Since such a code is primarily used for visitor or click tracking, this code needs to be inserted into every webpage of your blog.

Only then, the relevant tracking data would be collected from all the posts and pages of your blog.

 

Possible Solutions

Of course, you are not going to insert the code manually into all the pages and posts if you are using WordPress. Here are a couple of solutions.

 

1. Edit Theme Files

This is the most basic solution – you can open up the PHP files of your theme, and insert the code snippet at a relevant place.

Editing WordPress Theme Files Directly is Not Easy

Editing WordPress Theme Files Directly is Not Easy

However, if you do not know PHP, this can be difficult – even a small error like removing a semi-colon (;) can result into your posts and pages not displaying properly!

If you are a beginner blogger, I would advise you to stay away from this method. In any case, why do this when it can be done easily in other ways?

 

2. Use  a Plugin

A better option is to use a plugin that specializes in this – there are tons of plugins available that help you insert Google Analytics or other tracking code into the header and body sections of your webpages.

For a newbie, this is a great solution! Some popular options are:

You can look for more such plugins at http://wordpress.org/extend/plugins/.

 

3. Use Your Theme Settings

If you are using a good theme like Genesis, you don’t even need a plugin for doing this – you can paste the relevant code into the theme settings page, and it gets inserted into every webpage of your blog automatically!

Why bother with the overhead of a plugin when your theme itself can do this for you?

 

Inserting Google Analytics and Other JavaScript Code in Genesis Theme

Here is a smiple, step-by-step explanation of how you can insert any JavaScript code – including Google Analytics tracking code – into your blog using Genesis.

 

Step 1: Go to theme settings page

Log into your blog’s admin area, and go to Genesis > Theme Settings.

The theme settings page looks like this:

Genesis Theme Settings Page

Genesis Theme Settings Page

 

Step 2: Paste the Code

Scroll down to the bottom of the page – you would see a section called “Header and Footer Scripts”.

It looks like this:

Genesis Theme Settings - Inserting Header and Footer Scripts

Genesis Theme Settings - Inserting Header and Footer Scripts

 

Now insert the JavaScript code into the relevant box (the tracking service would tell you whether the code snippet needs to go into the header or the body / footer of your webpages).

Typically, the Google Analytcis tracking code snippet goes into the first box (wp_head()), and the Aweber tracking code goes into the second box (wp_footer()).

Now just hit the “Save Settings” button, and you are done!

PS: See how using a good theme makes things super-easy for you? You can read the full review of the Genesis theme and see why I love it – click here.

 

Enjoyed reading this post? Get articles about blogging, WordPress, getting traffic, making money, and more. Plus, get a FREE e-course "Make Money Blogging".
Just provide your details, and get started instantly!
No spam, guaranteed.
Name:
Email:

 

 

My blogs are hosted reliably at HostGator

I run 20+ blogs, and each of these is hosted at HostGator. I have been using their service for a long time, and have never experienced any downtime. They also have a very responsive customer service team.
 
HostGator provides the most reliable and fully featured WordPress hosting service. Their plans start as low as $3.96 per month for unlimited hosting - try out HostGator now!

Related Posts:

Speak Your Mind

*

More in Blogging Basics and Tools
Aweber Tips to Get the Most Out of Your Email List
7 Aweber Tips to Get the Most Out of Your Email List

You know that having an email list is vital to the success of your blog. That's why, you have subscribed...

Close