Posts Tagged ‘google analytics’

WordPress Theme Functions

January 9th, 2010 by Keith from shrewdies | 1 Comment | Filed in Form, Function
Functions and options bring flexibility to WordPress themes, but can they also over-complicate?

Flexibility is second only to speed in terms of theme importance.

There are risks when theme functionality goes too far, so you need to know where to draw the line.

Your WordPress theme is the face of your website – your front of house, if you like. Just like the real world, front of house has to present your features and benefits in your best light, and it has to direct visitors efficiently by providing comprehensive, consistent, accessible navigation.

Recent trends are to added customization options, and increase functionality. Feature that used to rely on plugins, especially custom RSS feeds and header/footer code, are now options in many themes.

Disappointed Digression
This Analytics problem highlights why my plea for keeping functionality out of themes is more than me being tetchy. A good Google Analytics plugin would recognize the need to track external links and include the necessary code. I believe at least one does this, but I will review them later. Managing the code is much more than just pasting the basic script into a box, and I believe it should be left out of themes.
If theme authors want to emphasize the importance of Google Analytics (or anything else) they can easily incorporate some Admin warnings without bloating the code for all users.

I was reminded of this today when I checked my Google Analytics, and realized the external tracking code[1] was missing. I always used to add this type of code manually to footer.php. It is very easy to do, but you must remember to change it whenever you change the theme.

To avoid disruption whenever I changed theme, I started using plugins to manage Google Analytics code, and other footer additions. Today, I realized that I can easily go to the theme options for this, and dispense with a plugin. That is tempting, as reducing plugins usually means a faster website. However, I’m not convinced that the theme option is the right place for this.

If I change my theme, I lose functionality. This cannot be right. If it was a WordPress standard, then I might accept that using an out-of-date theme could cause loss of functions. However, there is no standard here, so even if the new theme allows footer code to be added, I still have to remember to copy and paste it to the new theme.

I do wish theme authors would focus on polished presentation and nifty navigation. Give me CSS options and layout options, but please leave the functionality to the plugin authors. Better still, just move your functionality to your own plugin or integrate the features from a popular plugin that performs the same purpose.

WordPress Theme Functions: Next Steps

As we are all stuck with an undisciplined way of adding code to footers, unless WordPress produces a standard, we must ensure that we manage change properly. Footer code is easiest when managed with a plugin. If you want to save a little loading speed, use the theme options or theme editor, but be sure to have a proper change procedure for applying new themes. Such a change procedure covers preparing for and checking all theme dependent functionality, and I will write more on this later.

WordPress Theme Functions: References

Tags: , ,