gaTracker

gaTracker
 点击下载
This plugin is intended to simplify the process of adding Google Analytics tracking to a page, including the tracking of outbound links, mailtos, and downloads, which are not otherwise tracked by default. Calling the plugin does the following:
 
Determine whether to include the SSL or non-SSL version of the GA script.
Include the GA script (currently urchin.js, while ga.js is still in beta testing) from within try/catch to help suppress any issues GA may have from time to time.
Set the _uacct variable to your GA tracking code.
Call the urchinTracker() function once for the initial page load.
Examine all of the links on the page and attach onclick events to external links, mailto links, and downloads.
Call urchinTracker() when these links are clicked, prefixing them appropriately.
In addition to the tracking code, the prefixes used for each of the link types above, as well as the extensions considered "downloadable files" are configurable by the user.
 
It requires jQuery 1.2 or higher for the cross-domain $.getScript() call. Usage is simply:
 
  1. $.gaTracker('UA-XXXXX-XX'); 
Or you can specify options like so:
  1. $.gaTracker( 
  2.                 'UA-XXXXX-XX'
  3.                 { 
  4.                         external:       '/external/'
  5.                         '/mailto/'
  6.                         download:       '/downloads/'
  7.                         extensions:     [ 
  8.                                 'pdf','doc','xls','csv','jpg','gif''mp3'
  9.                                 'swf','txt','ppt','zip','gz','dmg','xml' 
  10.                         ] 
  11.                 } 
  12.         ); 

转载请注明:代码家园 » gaTracker

评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)