Question

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.

https://www.google.com/analytics/feeds/data?ids=ga%xxxxxxxxxx&dimensions=ga%3ApagePath&metrics=ga%3AuniquePageviews&filters=ga%3ApagePath%3D%3D%2Fusers%2Fuser_detail.php%3Fcode%3D0021-4432-5554&start-date=2012-02-29&end-date=2012-03-14&max-results=50

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.

I think I'm heading in the right direction, but would really appreciate some guidance here. Thanks!

Was it helpful?

Solution

Honestly implementing custom stats would be much better for a few different reasons. First of all 1 database insertion for every page view on the profiles is somewhat accaptable for small numbers. If the page starts creating a bottleneck then you could have an a sync request when the page loads.

What you could do is have one table for the stats. Id URI Click/action User profile Date

Then its easy to grab the amount of clicks and views.

If you go with Google you won't have as much freedom on what you can do with that data. 30k isnt a lot of rows and once you hit probably in the tens of millions of records you could start worrying about scalability.

But anywhere below that you should be fine.

EDIT:

I might add that google analytics does have a good api when working with analytics but you do limit your control on the data. Never the less for a long term approach and a statistics database can get extremely large extremely fast. Hitting the ten million mark with 30K users won't be too difficult. So if scalability is your main concern then maybe you would want analytics to handle it.

First you must register your application to use the api tools that google gives you: https://code.google.com/apis/console

But one issue is that the analytics api puts a courtesy limit on the number of daily requests at 50,000 queries/day. Though if you need more you may use this link to ask for more: https://docs.google.com/spreadsheet/viewform?hl=en_US&formkey=dGp3NEc0Z0dsX293V1UyckZtdDlGQmc6MA&ndplr=1

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.

Yes it is very much possible. Here is the Events API page: http://code.google.com/apis/analytics/docs/gdata/dimsmets/eventtracking.html

Another nice tool is available here: http://code.google.com/apis/analytics/docs/gdata/gdataExplorer.html

If you need more API references here they are: http://code.google.com/apis/analytics/docs/gdata/v3/gdataGettingStarted.html

Google provides many different apis for handling page views, events, reports. They also support many different languages for their libraries as mentioned above. You will be able to register an event(such as a click) and page views for a particular page(users profile). You will also be able to request all the statistics back onto your site for graphing or other needs.

Lastly, here is the api libraries toolkit for any particular language: http://code.google.com/apis/analytics/docs/gdata/v3/gdataLibraries.html

Hope this helps, Daniel

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top