Tracking Website Statistics With Google Analytics
Google Analytics is a competent, easy, and free website tracking tool used to find out key marketing data including:
1) How people reach your web pages
2) Where visitors click (links) once visiting one of your pages
3) How long visitors spend on each of your pages
4) The number of pages viewed per website visit
5) How many of your users have visited before (return visitors)
6) The browsers, operating systems, geographic locations, and monitor resolutions of your visitors
Analytics even allows you to set goals for your pages. Perhaps you would like to earn a dollar value in advertising revenue by a certain date, or have X number of visitors access one of your pages. Maybe you have a page path that you want visitors to follow, which is called a “funnel path.” This is all very simple to set up with Analytics.
How To Setup Google Analytics
Visit http://www.google.com/analytics and sign up for a Google account.
Once you have signed in to Analytics, you will need to add the tracking code to your web pages. It is my opinion that the best way to track pages is to create a separate file that is pulled into each one of your pages. For example, on this site I placed the Analytics code in a file called analytics.php. I then reference that file in my header.php, which is loaded on every page from the index.php file. If you’re new to this, don’t worry; it is less complicated than it reads.
Click on the “Add Website Profile” as shown in the image below.
Next, enter your website information and click on the finish button. Your Analytics code will be displayed along with the instruction to paste it in front of your </body> tag. This is where the PHP comes in.
Using A PHP File For Analytics
Instead of having to place your tracking code onto every single one of your pages, we can make a simple reference to the page that holds this code. This can be beneficial if we were to decide to change or delete our tracking code, since we would only need to edit our analytics.php file. Here’s the code to place in front of your <body> tag:
<?php include(“analytics.php”);?>
With a few seconds of thought, I bet you can guess what this bit of PHP does. Of course, it tells the page that it is located on to “include,” or “reference” analytics.php into the file. Now open up a new notepad (or your text editor of choice) and paste your Analytics code, saving the new file as the previously mentioned analytics.php.
Convert Your HTML Files To PHP
Since we are now utilizing PHP in our pages, we will need to change our .html to .php files. If you are convinced that you do not want to modify your pages due to breaking incoming links and potentially damaging your SEO efforts, learn how to bypass this problem.
Converting your HTML pages to PHP will also open up many additional opportunities to add interactivity to your site in the future. If you are new to web development, my advice is to always create your pages with the PHP extension; there is little reason to want to limit yourself to a static website.
When you are finished re-naming your files and uploading them to your server, you’ll notice that Analytics does not instantaneously display your website statistics. So with a day’s time to kill, let’s add a filter to exclude our own IP address from affecting our stats.
How To Add An Analytics Filter
Under the actions column of your Analytics home page, click the edit link. Scroll down to the filters section and click on the add filter link located at the top right corner of the section.
Add a new filter with a filter type that “excludes - traffic from the IP addresses – that are equal to” and then your IP address. If you are not sure what your IP address is, find your IP address. Save your changes.


Feed
E-Mail Friend
StumbleUpon
Digg
Facebook
Delicious
Technorati
Posterous
Yahoo! Buzz
LinkedIn
Leave a comment