title: Track Page Views and Events With Google Analytics or Custom Solution?
body: <p>I'm building a site that allows users to create a profile. Each profile page is identified in the query string by a unique 12-digit code. (http://www.site.com/users/user_detail.php?id=0021-4432-5554). I expect the number of profiles to eventually be 30-50k. I would like to provide each user with a profile to view analytics of their profile (page views, time on page, and click events on their page). Initially I built a custom solution using jquery and an external PHP file to insert records into a database table for each tracking event. This works well but I'm worried about scalability and thought GA might be able to do a better job. I've been digging around the GA documentation all day, but I'm still a bit unclear on the best way to implement this. My current approach is as follows:
  1) Insert GA tracking code in the profile page with event code for each click event I want to track.
  2) Use GAPI with the following code to display page views to users.</p>
  
  <pre><code>https://www.google.com/analytics/feeds/data?ids=ga%xxxxxxxxxx&amp;dimensions=ga%3ApagePath&amp;metrics=ga%3AuniquePageviews&amp;filters=ga%3ApagePath%3D%3D%2Fusers%2Fuser_detail.php%3Fcode%3D0021-4432-5554&amp;start-date=2012-02-29&amp;end-date=2012-03-14&amp;max-results=50
  </code></pre>
  
  <p>I am unsure of the following:
  1) Is this the best way to retrieve pageviews for a page identified by a querystring parameter? (matching the entire url vs just matching the 12-digit code with a regular expression)
  2) Is it possible to retrieve and display events such as clicks on the page using GAPI? I recall reading somewhere that the API couldn't be used for events.</p>
  
  <p>I think I'm heading in the right direction, but would really appreciate some guidance here. Thanks!</p>