Whatever your reasons, there are a few methods to accomplish this.
Option 1: Use Theme Settings
Here are some commonly used themes and links to their documentation:
Option 2: Use a Plugin
Each plugin will have a little different approach so you’ll want to reference the included documentation for your plugin of choice. We recommend sticking to top rated and highly used plugins.
Step 1: Add a new file to your theme
Let’s pretend we want to add Google Analytics code to our site. We create a new file named
js directory to keep things organized.
Step 2: Load the script on the site
Now we load this script on the site by calling
wp_enqueue_script within your active theme’s
jQuery which may be added as a dependency along with a version which allows for browser cache busting. This version includes both.
functions.php file. WordPress will not automatically wrap your code in
<script> tags so you have to make sure you do so. Using the below snippet you’ll want to replace
Here is an example of adding a full Google Analytics implementation this way.