Read Time:38 Second
원본 글: http://www.alfajango.com/blog/track-jquery-ajax-requests-in-google-analytics/
The code
This code will automatically log all jQuery AJAX requests in our application, including those using $.ajax()
, $.get()
, or $.post()
.
This will also work for any jQuery plugins using AJAX requests (e.g. lightbox plugins, etc.), as well as for all Rails 3 remote links and forms(provided we’re using the jQuery UJS driver).
In the page layout or in an included js file, we add the following JavaScript:
jQuery(function ($) {
// Log all jQuery AJAX requests to Google Analytics _gaq.push([‘_trackPageview’, settings.url]);
}); }); |
If we’re using this in a Rails 3 app, we can put this in our master.js
file.