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?


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.

  • There are many answers that say "use a plugin" but surely it is just as easy to create a child theme and make modifications that way? Sep 5, 2019 at 2:31

4 Answers 4


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.

  • 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, 2010 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, 2010 at 14:21

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.


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


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.

  • 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, 2010 at 6:01
  • Great clarification Sep 16, 2010 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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