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

Add Google Analytics Pageview #1198

Merged
merged 3 commits into from
Oct 9, 2019
Merged

Add Google Analytics Pageview #1198

merged 3 commits into from
Oct 9, 2019

Conversation

maple3142
Copy link
Contributor

@maple3142 maple3142 commented Oct 2, 2019

How to use?

In NexT _config.yml:

# Google Analytics
google_analytics:
  tracking_id: # <app_id>
  localhost_ignored: true
+ only_pageview: false

@stevenjoezhang
Copy link
Contributor

Can you confirm that the script is PJAX compatible? Because load event may only trigger once on the page, thus the callback function may not be executed after PJAX refresh.

@maple3142
Copy link
Contributor Author

@stevenjoezhang Is there a PJAX callback for doing that?

@stevenjoezhang
Copy link
Contributor

Is it possible to change the function from the callback of the load event to IIFE?

@maple3142
Copy link
Contributor Author

@stevenjoezhang Yes, but I wonder whether there's a way to detect if page changed(loaded by PJAX).

@stevenjoezhang
Copy link
Contributor

pjax:success event

@maple3142
Copy link
Contributor Author

This should now work with PJAX now.

1v9
1v9 previously approved these changes Oct 9, 2019
@1v9
Copy link
Member

1v9 commented Oct 9, 2019

Test passed when pjax enabled, I checked it in analytics realtime panel.

@1v9
Copy link
Member

1v9 commented Oct 9, 2019

Maybe combine GA functions and use united gtag.js, it's not difficult.

@1v9 1v9 dismissed their stale review October 9, 2019 15:29

gtag.js

@1v9

This comment has been minimized.

@maple3142
Copy link
Contributor Author

@1v9 In fact, the purpose of this PR is to have a basic analytics data without having to include bloated(IMO) analytics.js and gtag.js. Therefore, I am not interested to add them, since the normal version of GA already did much more than this script.

@1v9
Copy link
Member

1v9 commented Oct 9, 2019

@maple3142 OK I know, you mean a slimmer version to do less work

@1v9 1v9 merged commit 6619e38 into theme-next:master Oct 9, 2019
@1v9
Copy link
Member

1v9 commented Oct 9, 2019

Would you add docs for this feature?

@1v9
Copy link
Member

1v9 commented Oct 9, 2019

Wait, I have some work to do, I won't change the existing implementation, and I will push updates and documentation as soon as I'm done.

@maple3142
Copy link
Contributor Author

Added theme-next/theme-next.org@df36c7c

@1v9 1v9 modified the milestones: v7.5.0, 7.4.2 Oct 20, 2019
Liam0205 added a commit to Liam0205/hexo-theme-next that referenced this pull request Oct 22, 2019
- Add Google Analytics Pageview (theme-next#1198)

- Make font-size customized only when `theme.font.enable` is true (theme-next#1058)
- Point to different website based on the scheme (theme-next#1202)
- New Valine options (theme-next#1193)
- Improve the style of site-nav (theme-next#1180)

- Code style update (theme-next#1197, theme-next#1205)
- Replace id with class name (theme-next#1209)
- Add lang attribute to article tag when specified in front matter (theme-next#1199)
- Fix compatibility issues with hexo-util@1.3.0 (theme-next#1175)
- Optimize the loading of three.js (theme-next#1140)

- New README for NexT (theme-next#1155)

***

For full changes, see the [comparison between v7.4.1 and v7.5.0](theme-next/hexo-theme-next@v7.4.1...v7.5.0)
tongluyang pushed a commit to tongluyang/hexo-theme-next that referenced this pull request Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants