This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Sun Nov 01 10:43:06 -0800 2009 | |
| |
README.textile | Sun Nov 01 10:55:17 -0800 2009 | |
| |
src/ | Sun Nov 01 10:54:30 -0800 2009 |
README.textile
What’s GoogleAnalyticsProxy?
This class allows you to test event tracking in a development environment without throwing JavaScript errors because google analytics isn’t loaded. When Google Analytics is loaded, it’ll trigger the corresponding pageTracker functions as you’d expect in a production environment.
Example Usage
Just execute this after google analytics is loaded.
_gap = new GoogleAnalyticsProxy();
_gap._trackPageview();
_gap._trackPageview('/contact/thanks');
_gap._trackEvent('Video', 'Play', 'Homepage video');
_gap._trackEvent('Video', 'Pause', 'Homepage video');
_gap._trackEvent('Button', 'Click', 'Call to action X');
Initializing GoogleAnalyticsProxy
The following example is for Ruby on Rails to demonstrate how I load google analytics only in production, but GoogleAnalyticsProxy is loaded all the time.
<% if RAILS_ENV == 'production' -%>
<!--// Google Analytics //-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._trackPageview();
</script>
<% end -%>
<script type="text/javascript">
var _gap = new GoogleAnalyticsProxy();
</script>
Distribution
All the files related to GoogleAnalyticsProxy can be found in the src folder.
More information
You can learn morea bout the Google Analytics API here:







