It is essential and mandatory to install Google Analytics on your website if:
1)You want a track record of your site visitors
2)If you want your site to rank well in Google.
Let’s get started:
Firstly, you need to link your website to Google Analytics.
So search for Google analytics in Google search or just go straight to https://analytics.google.com/ , sign in to your gmail account.
After signing in, click on Sign Up at Google Analytics.
Click On Website since you want to link your website to analytics.
If it is an app you want to link to analytics, click on App.
Select your Industry Category
Select Your Country Reporting Time Zone
Then scroll down and click on Get Tracking Id.
At the section where you see This is your tracking Code. Copy and paste into the code of every page you want to track, you should see a long code in box, that is your tracking code. At the top, you would see your tracking ID, which starts with UA.
What you need here is your tracking code.
Be informed that if you install google analytics just on a single page, you would get tracking records for that page only.
For you to get tracking records for every single page on your website, you need to install google analytics at the Header.php of your website.
Immediately people hear php stuffs, they start shaking.
Do not be scared about coding, this is simple, trust me.
You can easily do this coding to permanently install google analytics on your website.
So highlight your tracking code and copy it.
Now go to your WordPress dashboard, go to Appearance, then click on editor.
At the editor page on your extreme right, click on Header(header.php).
At Header(header.php), a lot of codes would pop up, do not fear!
What you are to do here is to install Google analytics code at the Head of your website. By so doing, you would be able to track every page on your website.
So look for this <head>.
When you see this, just scroll down a little and look for </head>.
<head> is the opening of the site head and </head> is the closing.
You are to post the code in between.
Do not touch anything over here, else you will ruin your website. Just follow the instructions I’m giving.
Between <head> and </head> are some codes, don’t touch them.
Now click at the end of the code where you see
<?php wp_head(); ?>…..click just after the > the hit enter twice for spacing.
Then paste your code there.
It should look something like this:
<meta charset=”<?php echo esc_attr( get_bloginfo( ‘charset’ ) ); ?>”>
<meta name=”viewport” content=”user-scalable=yes, width=device-width, initial-scale=1.0, maximum-scale=1″>
<!–[if IE]><meta http-equiv=”X-UA-Compatible” content=”IE=edge” /><![endif]–>
<link rel=”pingback” href=”<?php echo esc_url( get_bloginfo(‘pingback_url’) ); ?>”>
<?php wp_head(); ?>
ga(‘create’, ‘UA-61482218-3’, ‘auto’);
My Google Analytics code is what begins with <script> and ends with </script>. I have put it in bold characters.
After installing your code, scroll down and update the file.
If you don’t do this properly and you mess up any code in there at header.php, you will ruin your website. Your website would crash.
To be on the safer side, before you post the code, copy everything at the header.php and paste it on microsoft word on your pc.
When you are done and you realise your site has been ruined, just go back to header.php, highlight all the codes and hit delete.
Then go copy the original code from word and paste it into header.php, then update to get your site back.
How to Verify If You Have Rightly Installed Google Analytics:
After you have successfully installed Google analytics, go to your website’s homepage, right click, then choose “view page source”.
At page source, click on ctrl+f(control find), then type in analytics.
If your installation was a success, you would see analytics pop up.
If it doesn’t pop up, go try the whole process again.
Just make sure you copy and save the original codes first at header.php on your PC, as backup, before you start.
If this tutorial was helpful, kindly subscribe to smart income office’s posts below: