Today I am excited to launch a small new plugin that embeds the Google Analytics Tracking Code inside your theme files dynamically without you needing to hard-code it in your template files. The plugin is called as GATCE
This is pretty useful if you frequently change your WordPress Theme files, and now you don’t need to worry about leaving out your Google Analytics code accidently just because you switched to a new theme.
You can download the plugin from WordPress.
How it works
This plugin is very simple and easy to use.
- Download the plugin and upload and unzip to your plugins directory as you would usually do.
- Activate the plugin from your WordPress Admin.
- Go to the plugin’s options page to add your Google Analytics Tracking Code. You can find the options page under Settings >> GA Tracking Code
- Save your changes. You have now successfully added your GA tracking code, and it will be automatically added to all your blog pages.
- To verify if your Google Analytics Tracking code has been added correctly, go to any of your blog page and View the source of your page. If the plugin is working correctly you should be able to see your Google Analytics tracking code inside the head tag or near to the end of the page (near to the closing </body> tag) depending on your settings. If you don’t see your Google Analytics code, please refer to the Prerequisites section below.
The plugin requires that your theme files have one of the following action/template tags depending on where you want to place your GA tracking code.
<?php wp_head(); ?>
If you want to place the tracking code inside the head section before the closing tag.
<?php wp_footer(); ?>
If you want to place the tracking code near page end/footer before the closing