As an experienced website operator familiar with Anqicms, I fully understand your need to integrate traffic statistics or spider monitoring functions into a single page.This can not only help you understand the page performance more intuitively, but also can display data to visitors in specific scenarios.AnQi CMS itself provides powerful backend data statistics functions, but to display these data on the frontend single-page, it requires some specific methods.

Anqi CMS's built-in monitoring capability overview

AnQi CMS is committed to providing users with efficient and customizable content management solutions, one of its core functions is traffic statistics and spider monitoring.The system integrates the website traffic analysis and crawler capture situation monitoring module in the background, which can accurately record visit data, spider tracks, inclusion status, etc.This data is crucial for optimizing our content strategy, adjusting SEO plans, and ensuring website security.As operation personnel, we usually check these reports in the "Data Statistics" module of the Anqi CMS backend to get a comprehensive understanding of the health status and user behavior of the website.

However, when it comes to integrating these statistics into the "single page" of the website, we need to differentiate the built-in features of AnQi CMS, which mainly serve backend data management and analysis, rather than being directly displayed on the front-end pages.This means that if we need to display traffic or crawler-related numbers on a specific single page, we need to adopt a different strategy.

Considerations and methods for single-page integrated traffic statistics

In AnQi CMS, integrating the traffic statistics feature into a single page is mainly divided into two cases: one is to use the fields provided by AnQi CMS itself (if the page type supports it), and the other is to integrate third-party professional statistical tools.

1. Use AnQiCMS built-in fields to display page views (suitable for article/product detail pages)

If what you mean by 'single-page' is actually an article in the AnQi CMSarchive) or a product (product) Detail page, congrats, AnQi CMS has built-in the views (Views) field, which can be directly called and displayed in the frontend template.

  • Implementation method:
    • Find the template file used in your article or product detail page. According to AnQiCMS template design conventions, this is usually located{模型table}/detail.htmlor{模型table}/detail-{文档ID}.htmlat the path.
    • In the template, use the tag to display the page views where you want.archiveDetailTo get the current document's page view data. For example:
      
      <div>
          阅读量:{% archiveDetail with name="Views" %}
      </div>
      
    • If you want to get the view count of a specific article or product, you can specify its ID:
      
      <div>
          ID为10的文章阅读量:{% archiveDetail with name="Views" id="10" %}
      </div>
      
      In this way, you can easily display the number of visits recorded by AnQiCMS internally on your article or product detail page, providing the user with certain reference information.

2. Integrate third-party professional statistical tools (suitable for all page types, providing more comprehensive data)

For a more comprehensive and detailed traffic analysis, or when your single page is a regular single page (pagetype, such as the "About Us" page, itspageDetailtags do not provide directlyViewsWhen integrating third-party professional traffic statistics tools such as Google Analytics and Baidu statistics, it is a more general and recommended practice.These tools not only can count the number of visits, but also provide rich dimensions of user behavior, source, bounce rate, and other data.

  • Implementation method:
    1. Select and register a third-party statistics tool:For example, Google Analytics 4 (GA4) or Baidu Statistics. Complete registration according to their official instructions and obtain your website tracking code.
    2. Get tracking code:These tracking codes are usually a segment<script>of JavaScript code enclosed in tags.
    3. Integrated into a single-page template:
      • specific single-page:If you only want to count on a specific single page (such as the "About Us" page), you can edit the custom template file of that single page. According to the AnQiCMS template conventions, the template file format of a single page ispage/{单页面id}.htmlYou can also specify a custom template for a specific page in the background "Page Management". Open the corresponding template file, paste the obtained tracking code into the HTML's</body>Before the closing tag. This ensures that the statistics code is executed after the page content is fully loaded, avoiding blocking the rendering of the page.
      • Whole-site deployment (including single-page applications):If you want to track traffic on all pages of the entire website (including all single pages, article pages, category pages, etc.), the most recommended practice is to place the tracking code in the public header or footer file of your template. It is usually in the root directory of your template.base.htmlFile, or you can go through{% include %}The general file introduced by tagspartial/header.htmlorpartial/footer.htmlFile. Similarly, it is recommended to place in</body>the tag before.
      • JS code injection point built into AnQiCMS:Although in the documenttag-tongji.mdmentioned `plugin