Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. window.addEventListener('load', function() {
  2.  
  3. // 支援Performance API才執行
  4. if(window.performance) {
  5.  
  6. // performance.now():頁面從最開始加載到目前為止的時間
  7. // Math.round:四捨五入取整數
  8. var timeSincePageLoad = Math.round(performance.now());
  9.  
  10. gtag('event', 'timing_complete', {
  11. 'name': 'load',
  12. 'value': timeSincePageLoad,
  13. 'event_category': 'GA user timing',
  14. 'event_label': location.pathname, // 拿頁面的路徑當事件標籤
  15. 'nonInteraction': true // 設成非互動式事件,以免影響跳出率
  16. });
  17.  
  18. }
  19. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement