Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Our situation is that we only dabble with Wordpress, however one of our Wordpress customers wishes to add Google Analytics to his site.

I'm assuming we can do this manually, relatively easily. And our instincts would be to go down that route. The customer is only small scale and won't need to do anything especially sophisticated, at least at this stage.

We want to keep this simple. Is it best to avoid a plugin?

Update

Thanks for all the great answers- in the end we did use a plug-in. As promised by the experts who answered below it was super straightforward.

share|improve this question
add comment

4 Answers

up vote 11 down vote accepted

I'd suggest either a plug-in or a drop-in section of code in your client's functions.php file. The advantage of a drop-in is that you can add it once and never have to worry about activating or managing the system once it's up-and-running.

Here's a quick explanation of how to add the Google tracking code to your theme's functions.php file. The code itself will be automatically added to the footer of every page, archive, and post. This is essentially what a plug-in will do, without requiring you to activate/administer the system within the WordPress UI.

Alternatively, you could use Google Analytics for WordPress to do the same thing within the UI.

The choice between plug-in or drop-in is entirely up to you. A drop-in takes about 10 seconds to add with copy-paste. A plug-in takes only slightly longer. The actual setup process within Google Analytics to get your tracking code will take longer than either approach.

share|improve this answer
    
hi, thanks for your answer. when you talk about a "drop-in section of code" and "adding the tracking code to your theme's functions.php" that's doing it the "manual" way as I understand it? –  hawbsl Sep 16 '10 at 8:43
    
It is a "manual" way to do it, but it leverages the dynamic nature of WordPress by using a hook to place the script in the footer rather than forcing you to locate the footer and place it yourself. If you can keep your theme changes just in the functions.php file it makes it far easier to upgrade the theme and port your modifications to newer versions (or other themes) when the time comes. –  EAMann Sep 16 '10 at 14:21
add comment

Use a plugin. Especially if you want it simple. Because plugin would take care of obscure stuff that won't even occur to you. Duplicate pages in Google index from their own Analytics tags is excellent example of such.

share|improve this answer
    
Great link! Thanks for the info. –  Larry Smithmier Sep 16 '10 at 2:22
add comment

this is one thing I always use a plugin for. Without question.

share|improve this answer
add comment

I suggest a plugin. As others have already argued on this site, custom code is asking for disaster on WP. When you use a plugin you have a ready made path to upgrades and enhancements. Avoiding customization of the WP core is critical and I have seen better results waiting for an enhancement than forcing it.

share|improve this answer
5  
For the record not a plugin and modify the core are very different things. There is functions.php file that is purposed and perfectly suited for many modifications and is upgrade-proof (if used correctly in child theme). Not even mentioning that code can be simply included in theme files/templates as well. –  Rarst Sep 16 '10 at 6:01
    
Great clarification –  RealityCramp Sep 16 '10 at 16:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.