Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baidu analytics 和 google analytics 在开启pjax后失效 #516

Closed
Lete114 opened this issue Mar 3, 2021 · 1 comment
Closed

baidu analytics 和 google analytics 在开启pjax后失效 #516

Lete114 opened this issue Mar 3, 2021 · 1 comment

Comments

@Lete114
Copy link

Lete114 commented Mar 3, 2021

问题:如题
开启pjax后,页面跳转后不统计的bug

解决

document.addEventListener('pjax:complete', function () {
    // 百度统计 Pjax
    if(typeof _hmt !== "undefined" && typeof _hmt.push === "function") {
      _hmt.push(['_trackPageview',window.location.pathname]);
    }
    // 谷歌统计 Pjax
    if(typeof ga === "function") {
      ga('send', 'pageview', window.location.href);
    }
    if(typeof gtag === "function"){
      gtag('event', 'pageview', {page_location: window.location.href});
    }
  })
jerryc127 added a commit that referenced this issue Mar 4, 2021
@jerryc127
Copy link
Owner

測試了
谷歌分析正常
百度統計沒適配,已更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants