在 Google Analytics 可以追蹤一些網頁中的事件,進而可以簡單對使用者行為模式分析,或是判定是否有達到目標的方法。
原本的 code 長這樣:
1234567891011
var_gaq=_gaq||[];_gaq.push(['_setAccount','YOUR_GA_ID']);_gaq.push(['_trackPageview']);(function(){varga=document.createElement('script');ga.type='text/javascript';ga.async=true;// ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';// Change to new way of gaga.src=('https:'==document.location.protocol?'https://':'http://')+'stats.g.doubleclick.net/dc.js';vars=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();
這邊加完之後,其實可以發現有宣告一個 _gaq 變數來放 Google Analytics 的設定,目前就只有設定帳號和紀錄 pageviews 而已。