0%

Statistics and Analytics

NexT will not send record to analytics service provider as long as the page's host name does not match url option set in site config file. This will prevent local debugging from polluting analytics. Make sure you have configured url correctly, otherwise these statistics tools may not work as expected.

Analytics Tools

Google Analytics

  1. Create an account and log into Google Analytics. More detailed documentation

  2. Edit theme config file and fill tracking_id under section google_analytics with your Google track ID. Google track ID always starts with UA-.

    next/_config.yml
    # Google Analytics
    google_analytics:
    tracking_id: UA-XXXXXXXX-X
    only_pageview: false
  3. When field only_pageview is set to true, NexT will only send pageview event to Google Analytics.
    The benefit of using this instead of only_pageview: false is reduce a external script on your site, which will give you better performance but no complete analytics function.

Baidu Analytics (China)

Login to Baidu Analytics and locate to site code getting page.

Copy the script ID after hm.js?, like the following picture:
NexT Baidu Analytics

Edit theme config file and change the value of baidu_analytics to your script ID.

next/_config.yml
# Baidu Analytics ID
baidu_analytics: your_id

Growingio Analytics

Official documentation: https://docs.growingio.com/v3/developer-manual/sdkintegrated/web-js-sdk/latest-jssdk

Edit theme config file and change the value of growingio_analytics to your project ID.

next/_config.yml
# Growingio Analytics
growingio_analytics: # <project_id>

Cloudflare Web Analytics

Edit theme config file and change the value of cloudflare_analytics to your project ID.

next/_config.yml
# Cloudflare Web Analytics
cloudflare_analytics:

Counting Tools

LeanCloud (China)

Adding article reading times counting to NexT theme. Documentation how to set the counter up and running safely aviable in hexo-leancloud-counter-security.

  1. Create an account or log in to LeanCloud, and then click the button to create an application in dashboard.
    LeanCloud
  2. Go to the application you just created, select Settings → App Keys in the lower left corner, and you will see your APP ID and APP Key.
    LeanCloud

Install hexo-leancloud-counter-security by executing the following command in site root dir:

$ npm install hexo-leancloud-counter-security

Edit site config file and add following content:

hexo/_config.yml
leancloud_counter_security:
enable_sync: true
app_id: <your app id>
app_key: <your app key>
username: <your username> # Will be asked while deploying if is left blank
password: <your password> # Recommmended to be left blank. Will be asked while deploying if is left blank

Edit theme config file and fill options under leancloud_visitors section.

next/_config.yml
# Show number of visitors to each article.
# You can visit https://www.leancloud.cn get AppID and AppKey.
leancloud_visitors:
enable: true
app_id: #<app_id>
app_key: #<app_key>
# Required for apps from CN region
server_url: # <your server url>
# Dependencies: https://github.com/theme-next/hexo-leancloud-counter-security
# If you don't care about security in lc counter and just want to use it directly
# (without hexo-leancloud-counter-security plugin), set the `security` to `false`.
security: true

Firebase

Firebase Analytics provides the functionality of visitor statistics.

Login to Firebase to get apiKey and projectId. The Web API Key gets generated once you go into the "Authentication" section for the first time.

Firebase

More detailed documentation

Edit theme config file and add or change firestore section:

next/_config.yml
firestore:
enable: true
collection: articles #required, a string collection name to access firestore database
apiKey: #required
projectId: #required

Busuanzi Counting (China)

Edit busuanzi_count option in theme config file.
When enable: true, global setting is enabled. If total_visitors, total_views, post_views are all false, Busuanzi only counts but never shows.

When total_visitors: true, it will show site UV in footer. You can also use font-awesome by setting total_visitors_icon to the name of the icon.

next/_config.yml
busuanzi_count:
total_visitors: true
total_visitors_icon: fa fa-user

When total_views: true, it will show site UV in footer. You can also use font-awesome by setting total_views_icon to the name of the icon.

next/_config.yml
busuanzi_count:
total_views: true
total_views_icon: fa fa-eye

When post_views: true, it will show page PV in post meta. You can also use font-awesome by setting post_views_icon to the name of the icon.

next/_config.yml
busuanzi_count:
post_views: true
post_views_icon: far fa-eye