NexT

Theme for Hexo

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 Hexo 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 NexT config file and fill tracking_id under section google_analytics with your Google track ID. Google track ID always starts with UA-.

    NexT config file
    # Google Analytics
    google_analytics:
    tracking_id: UA-XXXXXXXX-X
    only_pageview: false
    # only needed if you are using `only_pageview` mode, https://developers.google.com/analytics/devguides/collection/protocol/ga4
    measure_protocol_api_secret:
  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 NexT config file and change the value of baidu_analytics to your script ID.

NexT config file
# Baidu Analytics ID
baidu_analytics: your_id

Cloudflare Web Analytics

Official documentation: https://www.cloudflare.com/web-analytics/

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

NexT config file
# Cloudflare Web Analytics
cloudflare_analytics:

Microsoft Clarity Analytics

Official documentation: https://clarity.microsoft.com/

Edit NexT config file and change the value of clarity_analytics to your project ID.

NexT config file
# Microsoft Clarity Analytics
clarity_analytics: # <project_id>

Matomo Analytics (Self-managed)

Edit NexT config file and fill server_url and site_id under section matomo with the url of your backend server and your customized site ID.

NexT config file
# Matomo Analytics
# See: https://matomo.org/
matomo:
enable: false
server_url: # https://www.example.com/
site_id: # <your site id>

Umami Analytics (Self-managed)

Umami is a self-hosted web analytics solution. Official documentation: https://umami.is/

Edit NexT config file. Fill script_url under section umami with your tracking script URL, and change the value of website_id to your website ID.

NexT config file
# Umami Analytics
umami:
enable: true
script_url: # https://umami.example.com/script.js
website_id: # <your website id>
host_url: # <your umami site url>

Plausible Analytics (Self-managed)

Opt for paid managed hosting or self-host it on your server. Official documentation: https://plausible.io/

Edit NexT config file. Fill script_url under section plausible with your tracking script URL, and change the value of site_domain to your website domain.

NexT config file
# Plausible Analytics
plausible:
enable: true
script_url: # https://plausible.io/js/script.js
site_domain: # www.example.com

Counting Tools

Firebase

Cloud Firestore provides the functionality of visitor statistics without loading the Firebase JavaScript SDK.

  1. Create a Firestore database in Firebase console.

Firestore
Firestore

  1. Apply these rules in Firestore Database Rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /articles/{document} {
allow read: if true;
allow create: if request.resource.data.keys().hasOnly(['count'])
&& request.resource.data.count is int
&& request.resource.data.count == 1;
allow update: if request.resource.data.diff(resource.data).affectedKeys().hasOnly(['count'])
&& request.resource.data.count is int
&& request.resource.data.count == resource.data.count + 1;
allow delete: if false;
}
}
}

Replace articles if you use a different collection name. These rules allow anonymous reads and count increments while preventing changes to other fields and document deletion. They cannot prevent artificial increments or quota abuse; use a trusted backend if stronger protection is required.

Firestore

Find your Project ID in Firebase console under Project settings → General, then edit NexT config file and add or change the firestore section:

Firebase Project ID

Only the Project ID is required. The Web API Key shown on the same page is not used by NexT.

NexT config file
firestore:
enable: true
collection: articles #required, a string collection name to access firestore database
projectId: #required

An API key is not required. NexT uses the Cloud Firestore REST API, and anonymous requests are authorized by your Firestore Security Rules.

Note: Firestore visitor counting records at most one visit per article and browser profile because it uses the browser's localStorage. It is not a reliable unique-visitor metric. To test the counter:

  • Clear localStorage in Developer Tools
  • Use incognito/private mode
  • Use different browsers

Busuanzi Counting (China)

Edit busuanzi_count option in NexT 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 file
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 file
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 file
busuanzi_count:
post_views: true
post_views_icon: far fa-eye
0%