Here we will cover how to install Google Analytics onto a website.
After Google Analytics is set up with Google, Google provides a Global Site Tag code snippet to insert into every webpage that needs to be tracked. A different tracking tag must be used for each website when managing multiple domains in Google Analytics.
To get the Google Analytics code snippet, a Google Analytics Account must be created and activated for Analytics. We will cover the process of how to add the code here.
Related Articles
Google Website Verification
Have Google Recrawl a Website
Installing Google Analytics in WordPress
NOTE: Steps for installing Google Analytics on non-WordPress sites can be found below these steps.
- Log into your Google Analytics account to get the Global Site Tag
- Installing Google Analytics via a Plugin
- It's possible to install Google Analytics through a plugin such as MonsterInsights
- For detailed steps on installation and setup, view the support forum for the plugin
- It's possible to install Google Analytics through a plugin such as MonsterInsights
- Installing Google Analytics via the header.php file
- Copy the code that was received from Google
- Log into the WordPress Dashboard
- In the panel on the left, hover over Appearance and click Theme Editor
- A typical WordPress theme will have a Theme Header (header.php)
- Find and click on this file in the list on the right
- This will open the file in the editor
NOTE: If there is no header.php file, a different method should be used.
- Add the code into the theme’s header.php file inside of the
<head>
section
TIP: The<head>
section can be identified by an opening<head>
tag and a closing</head>
tag. The code can be placed in between those two tags.
- Copy the code that was received from Google
- Installing Google Analytics via the functions.php file
- Copy the code that was received from Google
- Log into the WordPress Dashboard
- In the panel on the left, hover over Appearance and click Theme Editor
- A typical WordPress theme will have a Theme Functions File (functions.php)
- Find and click on this file in the list on the right
- This will open the file in the editor
NOTE: If there is no functions.php file, a different method should be used.
- Add the following code to the bottom of the theme’s functions.php file
add_action( 'wp_head', 'my_own_analytics', 20 );
function my_own_analytics() { ?>
// Paste your Google Analytics code here
<?php
}REPLACE: // Paste your Google Analytics code here with the Google Analytics Code provided by Google.
- Update the file by clicking Update File under the editor
- Copy the code that was received from Google
Manually Installing Google Analytics
NOTE: This method can be used for most non-WordPress websites. If you are using a different content management system (CMS) and the below steps aren't working, a developer should be consulted.
- Log into your Google Analytics account to get the Global Site Tag
- The code will need to be entered on every page to be tracked between the
<head>
and</head>
tags
NOTE: If the site is using PHP to dynamically build the headers from a separate file, the code would need to be inserted into that file.