The native theme of Hexo comes with Google Analytics, but Google Analytics does not work well in China. After some consideration, I added Tencent Analytics from the Next theme to the Yelee theme I am using.
By the way, Tencent Analytics is really the best website statistics software I have ever used.
I am using the Yelee theme, which does not have Tencent Analytics, so I added it myself.
Perform the following operations in the "theme directory".
Add the following code to the "_config.yml" file:
tencent-analytics:
# Configure your Tencent Analytics ID after the colon. The ID is the numeric part of the code you obtained.
Create a new "tencent-analytics.ejs" file in "layout/_partial/". Add the following code:
<% if (theme.tencent_analytics){ %>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=<%= theme.tencent_analytics %>" charset="UTF-8"></script>
<script type="text/javascript">
var _speedMark = new Date();
</script>
<% } %>
The above code includes Tencent Analytics.
Modify "head.ejs" in "layout/_partial/":
# Add the following code on any line to load Tencent Analytics when users open the webpage.
<%- partial('tencent-analytics') %>
Then enter your Tencent Analytics ID in the "_config.yml" file of the theme.
Execute the following commands:
hexo clean
hexo g -d
That's it.