Database Statistics

Ever wonder how much space your database is utilizing? Usually something we don’t give much thought to, however if you are looking into migrating hosting then it is something you may need. I tend to work on a lot of WordPress Sites that utilize MySQL databases and the below 2 queries I have found to

Google Analytics: How to manage and use Profiles and Filters

Google Analytics has powerful filtering functionality for users to easily segment their statistics to track views of sub-directories, sub-domains, traffic sources, as well as a multitude of other filtering options. These may seem confusing the first time you use them but once you understand how filters work you will find them a handy tool. Filters

Google Analytics API

Tired of accessing Google Analytics via their web interface to obtain your web statistics? Great news Google has released a beta version API for accessing the analytics data.  For the full documentation you can access the official google labs page. As with most APIs google does place a quota on the calls you can make

Google Analytics Quick Start Guide : Part 3 – Campaign Tracking


Part 1 and Part 2 of the Quick Start Guide showed how to include Google Analytics on your website and how to track internal searches and content links. In the final chapter of the Guide we will look at how to track how users come to your site by the use of Campaign Tracking.  Please note that by default the source that the user comes to your site will be recorded this section explains how to get detailed information about ad tracking.

Understanding the Basics

Google Analytics allows you to tag your urls with 5 parameters for tracking visitors source. The 5 parameters are:

  • Source – The Campaign Source defines where the visitors are coming for these could be email newsletters, websites, etc.
  • Medium – The Campaign Medium defines by what medium they were directed to your site for example, banner ad, email, cpc (cost-per-click)
  • Name – The Campaign Name defines the name of the campaign this link is associated with for example you could be running a Summer Promotion and have various banners and emails in the campaign.
  • Term – The Campaign Term contains the search term the user used to find this link, this is most commonly used for keyword searches
  • Content – The Campaign Content defines information about the content associated with the link. For example if you have 2 different versions of a banner ad that are both part of the same campaign you could have their content set to Version A and Version B to distinguish which banner ad version the visitor clicked on.

How to create the campaign link

To help build your links Google Provides a Link Builder Tool. However to be comprehensive you could create a link manually by replacing -FIELD- with the value for the given field. Also note that you do not need to have all the fields in every link only use what you need.

Please note that the portion before the ? will be swapped with the url of where you would like the user to end up on your site.

Customizing the Campaign Link

In the case that you utilize multiple analytics packages or that you have parameters set up within your website that don’t correlate to the ones above you can modify the parameters associated with the campaign tracking. The API Calls are listed below.

  • Modify Source
    _setCampSourceKey ( “value” )
  • Modify Medium
    _setCampMediumKey ( “value” )
  • Modify Name
    _setCampSourceKey ( “value” )
  • Modify Term
    _setCampTermKey ( “value” )
  • Modify Content
    _setCampContentKey ( “value” )

These calls will have to be made prior to the_trackPageview() call. An example is below.

var pageTracker = _gat._getTracker("UA-6713355-1");

The sample url would be”Start Guide”

Understanding Output

To view information obtained from campagin tracking you will need to access the Traffic Sources Reports following the below instructions.

  1. Sign-in to Google Analytics at
  2. Select Account to View
  3. Select View Report for the Profile you want to view
  4. Select Traffic Sources from the left Navigation

Using the sub-reports you will be able to find out details about your campaign. If you select Campaigns you will be able to see how the individual campaigns are doing in relation to each other. Selecting Ad Versions will display information based on the Content parameter.  Last but certainly not last selecting All Traffic Sources will display for you  the Source/Medium combination for your site example / banner.


Be warned that google tracks query urls as seperate pages, this is in the case that your pages contain dynamic content. To filter out query parameters that do not affect content you will need to enter parameters into the Exclude URL Query Parameters in the Edit Profile page by following the below steps.

  1. Return to Analytics Settings Page
  2. Select Edit for the Account Profile
  3. Select Edit for the “Main Website profile Information” section
  4. Enter query info into the “Exclude URL Query Parameters” each parameter separated by a comma, if by example you use a custom source query parameter of “source”, and a custom keyword paramter of “keywords”. you would want to put source, keywords into this
  5. Save Changes
  6. Now pages with different above query parameters will not be saved as separate pages.


That wraps up the Google Analytics Quick Start Guide.  You should now know how to set-up and gather analytics on your site including tracking of content links, site searching, and advertising campaigns.  There are many more features available within Google Analytics so don’t hesitate to explore or simply stay tuned for additional advanced articles.

// Analytics //

Google Analytics Quick Start Guide : Part 2 – Tracking Links and Site Search


In Part 1 of the Quick Start Guide we learned how to setup Google Analytics on your web site. In part 2 we are going to learn how to track links on your site that either download content or take users to a different site. Also we will learn how to configure tracking of site searches, If your site has search capabilities.

Link Tracking

Link tracking is a method to track link clicks as a page view within Google Analytics. Please note that you do not want to add additional tracking to navigational links within your site.  The basic Google Analytics code included on those pages will track. Link Tracking is used to track links that either take a user to a different site, tracking how many time a file was downloaded, or if your site utilized AJAX to dynamically update elements on the page you could track if a user sees the dynamic content.

How to Track a Link

  1. The page must include the Google Analytics code in it from Part 1
  2. Add pageTracker._trackPageview(‘url’); to the onclick function of the link


<a href="" onClick="javascript: pageTracker._trackPageview('/outgoing/');">

Additional Notes

  • The User must have Javascript enabled for the link to be tracked
  • To view the link clicks simply access your google analytics account and the link will show up as a page view within the “Content Overview” section.

Site Search

Site Search is a element that allows the user to input a search query and be provided with results to possible pages that match the query they entered. A basic search would allow the user to input a string and return pages that contain the string or tokens (words) in the string. If your site contains a search feature you can enable Google Analytics to track what your visitors search for, this can give you a better idea of how to organize your content.

How to Enable Site Search

  1. Login to your google analytics account
  2. Select the Account that you want to enable site search for.
  3. Select “Edit” under the actions for the profile you want to enable site search on.
  4. Select “Edit” on the right of the section called “Main Website Profile Settings”
  5. Scroll down to the section entitle Site Search
  6. Select “Do Track Site Search”
  7. In the Field “Query Parameters” enter the url paramater that the search string is passed to the search page.  This can be any string but for example /search/?query=Test Search would be query
  8. If desired you can select “Yes, strip query parameters out of URL” so that each unique search query does’nt get tracked as its own page
  9. Click “Save Changes”
  10. Site Search is now enabled on your site

How to View Site Search

To view what users have searched for on your site you would follow the following steps from the Dashboard screen that is accessed by the “View Report” link on the Account Profiles page.

  1. Select Content in the left navigation to expand its sub options
  2. Select “Site Search” from the options within “Content”

From the Site Search Report page you can gather basic information on how many vistors used search, how many searches, and additional information. If you want to see what users are searching for select “Search Terms” in the left navigation within “Site Search”.


Tracking non page links and site searches will help you determine what content on your site visitors find useful.  Using this information will help you refine/ or expand your site to increase traffic and user satisfaction. In part 3 of this guide you will get introduced to “Campaign Tracking” which lets you enhance tracking of how users got to your site via advertisements (banner ads, text links).

// Analytics //

Google Analytics Quick Start Guide : Part 1 – Setup


Google Analytics is a easy to install analytics package useful for tracking activity on both small and large websites. This 3 part guide outlines how to setup and install google analytics on your website as well as explaining the basic information you can get out of the system e.g. Site Visits, Page Views, Bounce Rates, traffic sources, and etc.  I recommend installing analytics on every site you develop as it takes a matter of minutes, and can give you valuable insight into what information on your site visitors are looking for.

Setting Up Your First Account

Setting up your first account is as simple as filling out a few forms.

  1. Go to the google analytics site at
  2. If you don’t have a google account, create one by selecting the  “sign up now” link and following the instructions. If you do have an account proceed to step 3.
  3. Sign in to your account – this should take you to the Account Overview page listing all of your analytic accounts.
  4. Create a new analytics account by selecting “+ add new account”
  5. On the getting started page select the “Sign Up” button.
  6. Next you will be prompted to enter the site information including url, name, country, and time zone.  Once entered press “continue”
  7. On the following screen enter the primary contact for the analytics account, unless this account will be handled by a client enter your information. Press “continue” once completed.
  8. After you enter the contact information you will be prompted to accept google’s privacy policy, you will need to select “yes” to continue. In addition you can also modify the account’s data sharing with google and non-google applications. I personally select Share “with other Google products only”
  9. Click “Create New Account”
  10. Copy the code displayed under the “New tracking Code (ga.js)” and paste it into a document.
  11. Click “Finish”, you should now be back on the overview page displaying your new account.

Installing the code into your site

It is recommended that you place the tracking code copied from step 11 above into your web page right before the closing </body> tag. This way the page is loaded before the tracking code runs. You will need to do this for every page of your website, if you are using a language such as php to output your web pages it would be a good idea to place the code in a separate file that is included in all your pages. Doing so will keep your from modifying your entire site if you need to modify settings in the future. You do not need to make any modifications for if your site is using ssl as the script checks the protocol being utilized.

Once you place your files live on your server tracking will now be functioning.  Please note that you will not see information in real time and will see information up to the previous day.

  <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));
  <script type="text/javascript">
    try {
      var pageTracker = _gat._getTracker("UA-6713355-1");
    } catch(err) {}

Understanding the Basic Reports

To view the statistics of your site you will need to log back into google analytics. Once logged in select the analytics account for the site you want to view data on by clicking on the name.  You will now be presented with the profiles set-up for this account select “view report” to go to the report dashboard.  On this page you can get the basic stats of your site.

  • Site Usage
    • Visits – How many visits have there been to your site
    • Pageviews – How many pages have been viewed on your site in total
    • Pages/Visit – On average how many pages does a visitor view
    • Bounce Rate – What percentage of people come to this page then immediately go somewhere else
    • Avg Time on Site – How long does a visitor stay on the site
    • New Visits – Percentage of new visitors to the site
  • Visitors – Displays the number of visitors to your site, note that the number of visitors may be less then the number of visits as a visitor my visit your site multiple time
  • Map Overlay – This feature gives you a global view of where visitors of your site are from and you are able to click in to a state view as well.
  • Traffic Sources Overview – This area displays how users are getting to your site, from direct traffic(typing in the url) search, referral from other sites, etc.
  • Content Overview – The Content Overview lists out the top viewed pages in your site. This area can be used to determine what pages users find helpfull and ones that they don’t.

Conclusion & Next Steps

That concludes Part 1 of the Google Analytics Quick Start Guide, you should now know how to configure google analytics into your websites and what some of the basic stats are that you can retrieve from the system to enhance your visitors experience.  The introduction is continued in Part 2 – Link tracking and Site Search

// Analytics //