Tag Archives: wordpress

How To Implement Google Analytics Tracking in WordPress Website

Google Analytics is powerful and free tool which provides all possible information about website audience.

To install Analytics tracking code on WordPress website, there are two basic ways:

Use Google Analytics Plugin

The method is to use specialized plugin. One very popularĀ is plugin Google Analytics by Yoast. It has a lot of options, and even a payable Premium edition. Yoast is integrated with Google Analytics and provides a lot of data inside WordPress backend.

If you are not technical person, their free version is probably method you should choose. Just install plugin from Plugins section of Dashboard, set Analytics login information and you’re done.

Insert Google Analytics tracking code directly in theme code

For me, it’s a little too much to install big plugin just to place few lines of tracking code. Yoast has additional features, like showing of Analytics data directly in WordPress Dashboard. But, I prefer to load directly to Analytics website since there I see more information.

One option is to insert tracking code to footer.php or header.php file of WordPress theme. Go to Dashboard -> Appearance -> Themes -> Editor page and click on Header on file list on right side. Place Google Analytics code just before ending </head> tag. Click Update File button to save the changes.

This option is also pretty easy and fast, and there is no additional plugin involved. However, there is one flaw. Since you edit theme file, if you update theme later to new version, that will remove tracking code too. So, you can either not update theme after you install Analytics tracking code, or add it again on same way after theme update.
Sometimes this is good enough, like when you use custom theme and have full control over update process.

Finally, I found Super Simple Google Analytics. It’s small plugin which only inserts Google tracking code on right place and nothing else. On this way you can avoid huge plugin and also Analytics tracking code will survive theme update.

How To Colorize Source Code Snippet In WordPress Post

There are lots of WordPress plugins for colorizing source code syntax, and many of them are pretty good.

Two most impressive I found are Crayon Syntax Highlighter and SyntaxHighlighter.

Both are great, and it’s hard to decide which is better. Both probably have more options than common user needs. Finally, I decided to use Crayon because it has slightly better ranking in WordPress plugins directory. Here is one small sample:

// Hello World in JavaScript
alert('Hello World!');

Websites hosted on WordPress.com have pre-installed syntax plugin. To place source code in article on blog hosted on WordPress.com, just use [sourcecode] or just [code] tag in text view. For previous code example if your blog is on WordPress.com you, should write something like this:

[code language=”javascript”]
// Hello World in JavaScript
alert(‘Hello World!’);
[/code]

More info about this feature you can find on http://en.support.wordpress.com/code/posting-source-code/