Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use google analytics to track calls to a json response?

I am working on a app that uses a json response from my Zend Framework 1.10 website. I want to track how many times the Json Action is hit?

If there is no true way to do this from just the action that is not reflected the json response.

like image 382
AlbertRosa Avatar asked Dec 17 '25 22:12

AlbertRosa


1 Answers

I would suppose you are using Jquery to illustrate my idea , I would track both success and error function of jquery using google analytics events

   example :  pageTracker._trackEvent(category, action, opt_label, opt_value );

  Guide : http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html



$.ajax({
......... some jquery code here .....

success:function(){
......... Jquery code ...........
/*lets show some magic */
pageTracker._trackEvent("JSON", "SUCCESS", "Loaded" , 1 );

},
error:function(){
.......... Jquery code ...........
pageTracker._trackEvent("JSON", "FAILD", "why it faild " , 0 );
}
})

at the end of the day , go to Events on you GA Account you would see handy results as you would expect :) you can track ( click , AJAX Request , Page load time , Banner & many other smart ideas )

another tip : you might use what GA Marketers used to do

this is the most easiest one to make http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55578 just append it to your AJAX request and watch the magic :)

Twitter using this idea in the mailing notification example :

http://twitter.com/*********?utm_campaign=newfollow20100823&utm_content=profile&utm_medium=email&utm_source=follow

like image 81
tawfekov Avatar answered Dec 19 '25 20:12

tawfekov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!