In our previous article we covered the initial setup for Google Analytics
. In this article we'll cover implementing Google Analytics for your website. If you have not yet signed up for Google Analytics, please review our previous article for step-by-step instructions.
Obtaining the Google Analytics Tracking Code
Let's pick up where we left off in our previous article. We've signed up for and logged into our Google Analytics account. If you're not already on the Tracking Code screen, click on the gear icon in the upper right area of the screen to take you into the management area and then click on the "Tracking Code" tab.
For our purposes, we will be installing Google Analytics on a single domain. If your site has subdomains or multiple top-level domains you want to install this for, make the needed selection in Step 1 of this screen. You can also setup separate profiles for separate sites.
Scrolling down, in Step 2 you'll see code to be copied and pasted into your site's files.
Once you've copied your code, click the Save button at the bottom of this screen.
You may want to bring up a text editor (such as Notepad or TextEdit) and paste the code in there while you work through the steps to bring up your site files for editing.
Inserting the Google Analytics Code into your Site
How you insert the code will depend on how you build your site. Keep in mind that you will need to insert the code into every page you wish to track with Google Analytics.
If you are dynamically creating page headers (with PHP for instance) you will want to place the code into the files called to create your headers.
If your site is built with HTML, you can either use your design software or the Editor in cPanel File Manager to edit your files.
While the basic instructions from Google Analytics state to paste the code before the closing </head> tag, you can actually insert it anywhere within your site (according to Google's support forum). It is recommended to place it as high in your code as possible. So, if you are using our Premium Website Builder to create your site, you can use the script module in Step 4 - Edit on each page where you wish to insert your code.
Inserting Google Analytics Code into a WordPress Site
While you can manually insert the Google Analytics code into WordPress files (footer or functions files) we recommend using a plugin since code pasted into theme files could be overwritten by theme updates and would not automatically be copied over to their respective files if you switched themes.
You can search WordPress plugins for Google Analytics and review the various results. Two of the most popular and highly rated plugins are:
Google Analytics for WordPress
Google Analytics Dashboard
Testing Google Analytics Installation
To test your installation of Google Analytics, you can check the status from your Google Analytics account. You can easily change from the beta view to the classic view by clicking on the "Old View" link in the upper right of your screen in Google Analytics. Once in the classic view, you should see a clock (tracking installed) or a green check mark once you have reports to view for your site.
Once you have inserted the code for each of your pages you wish to track, you can begin using your Google Analytics Account to track your website traffic.