Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.addEventListener('load', function() {
- // 支援Performance API才執行
- if(window.performance) {
- // performance.now():頁面從最開始加載到目前為止的時間
- // Math.round:四捨五入取整數
- var timeSincePageLoad = Math.round(performance.now());
- gtag('event', 'timing_complete', {
- 'name': 'load',
- 'value': timeSincePageLoad,
- 'event_category': 'GA user timing',
- 'event_label': location.pathname, // 拿頁面的路徑當事件標籤
- 'nonInteraction': true // 設成非互動式事件,以免影響跳出率
- });
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement