The tools and plugins recommend in the site are the ones we use, have tried ourselves and recommend our readers. Marketing With WP is supported by readers like yourself. If you take an action (such as a purchase) after clicking on our affiliate links, we may earn some coffee money to create more helpful articles. As always, we thank you for your support.
Website owners need to add tracking codes to WordPress website to implement analytics, tracking and syncing data with external services.
Below are some of the most common tools that require adding tracking code in your website:
- Google Analytics
- Facebook Pixels
- Google Tag Manager
- Marketing Automation tools
- Google Search Console domain verification
- Facebook Domain verification
The easiest way to implement tracking code on your WordPress website is with a WordPress plugin that allows to add tracking code to the header, body or footer area of your site.
Find out how to add tracking code to your WordPress website easily with the following step by step guide.
Why use a plugin to insert tracking code?
Convenience: It is easier and more convenient to use a plugin instead of modifying theme files.
The traditional method to add tracking code was by adding the code in core theme file (functions.php and header files). Modifying the theme file also meant the tracking code being deleted each time the theme was updated. Site owners had to add the tracking code each time core theme file was updated.
Using a plugin does not remove the tracking code each time a theme is updated.
Safe: Modifying theme files is risky and dangerous. One small error can cause the site to break. With a plugin, you can control exactly where you want your tracking code to be implemented.
With a plugin, you set it and forget it and the tracking codes stay intact even after theme file updates.
Option 1 – Use SEOPress SEO Plugin
We use SEOPress as our core SEO plugin. SEOPress has a built-in feature to add tracking code in the core plugin itself. To add your tracking code –
Step 1) Go to SEOPress Dashboard
Step 2) Go to Manage Analytics >> Tracking
Step 3) Click on Tracking
Step 4) Insert Tracking Code
Step 5) Click Save Changes
Step 6) Clear cache if you have caching enabled
Step 7) Test if tracking code is implemented by opening a new private window / incognito mode
Option 2 – Use Insert Header Footer Plugin
If your SEO plugin does not have a place to insert tracking code, you can add a header footer plugin.
You can add the tracking code easily by –