Does AnQi CMS provide an integrated JS statistics code calling tag for easy display on the page?

Calendar 👁️ 57

When using AnQiCMS, many users are concerned about how to conveniently integrate third-party JavaScript statistics code into the website page, such as Baidu statistics, Google Analytics, and so on.About this, AnQiCMS indeed provides built-in mechanisms and flexible template tags that allow you to easily call and display these statistics codes on your website.

Utilize the integrated JS code calling tag

AnQiCMS to meet the needs of website operators to integrate third-party scripts, especially for some services that require data submission or statistics through JavaScript, provides a special built-in tag.In the background function management, there is an option called "Link Push", which includes the function of "360/Toutiao and other JS automatic submission".Although this feature was initially designed for JS push links in search engines, its underlying implementation is a general JS code injection mechanism.

You just need to paste the complete JavaScript statistics code (including<script>and</script>The tag), the system will store it. Subsequently, in the front-end template of your website, you can call and display this code through a specific tag. This tag is{{- pluginJsCode|safe }}.

This tag is usually placed in the public template file of the website (such asbase.html)的<head>or within the tag</body>Before the end tag.|safeThe filter plays a crucial role here, telling the template engine that this content is safe HTML/JavaScript code that does not need to be escaped, thus ensuring that the statistical code can be correctly parsed and executed by the browser.This way, no matter which page of your website the user visits, the statistics code will automatically load and start collecting data.

Flexible invocation through customized system parameters

In addition to the built-in tags for specific scenarios, AnQiCMS also provides another more general method for managing and calling custom JS code, which is to use the 'Custom Parameters' feature in the 'Global Function Settings'.

In the background "Background Settings" -> "Global Function Settings", you can add custom parameters.For example, you can create a parameter named "AnalyticsCode" or "BaiduTongji" and paste your JS statistics code in the "Parameter Value" field.The advantage of this method lies in the ability to create multiple independent custom parameters to store different JS code snippets, such as one for Google Analytics, another for Baidu statistics, or any other JS script that needs to be globally loaded.

You can use these custom parameters when calling in the front-end template{% system with name="您自定义的参数名" %}tags as well, which need to be配合|safefor example:{% system analyticsCode with name="AnalyticsCode" %}{{analyticsCode|safe}}This way provides higher flexibility, you can control the loading location and conditions of each JS code snippet as needed, making website management more refined.

The difference between AnQiCMS's own traffic statistics and external JS statistics

It is worth mentioning that AnQiCMS itself also provides the core function of "traffic statistics and crawler monitoring", which can help users understand the access situation of the website and the crawling dynamics of search engine crawlers.But this is a system internal data analysis function, which is different from the concept of integrating third-party statistical tools (such as Google Analytics, Baidu Statistics, etc.) that we discussed.The built-in traffic statistics focus on providing basic data at the CMS system level, while integrating third-party JS statistics code allows you to use more professional and feature-rich external statistics services.

In summary, AnQiCMS provides specialpluginJsCodeLabel and flexible custom system parameter in two ways, fully meet your needs to call JS statistical code on the website page.These methods are very intuitive and easy to operate, simply configure them in the background, and introduce the corresponding tags in the template to seamlessly integrate third-party statistical code.


Frequently Asked Questions (FAQ)

  1. Can I use multiple JS statistics codes on the website at the same time? For example, using Google Analytics and Baidu statistics.Certainly, it is completely possible. You can paste different statistical codes separately into the input boxes for '360/Toutiao and JS automatic submission' (if there is enough space and they do not conflict), or a more recommended approach is to create two independent custom parameters in the 'Global Function Settings', such as 'GoogleAnalyticsCode' and 'BaiduTongjiCode', and then paste the corresponding JS code into them.Finally, call these custom parameters separately in the template.

  2. Where is the most appropriate position to place the JS statistics code in the template?Generally speaking, it is recommended to place the JS statistics code in the public template file of the website (such asbase.htmlor the main layout file) of<head>Tags inside, the sooner the better, to ensure they are executed as early as possible when the page loads and capture all access data. In some cases where large or complex statistical scripts may affect the page rendering speed, it can also be considered to place them inside</body>Before the closing tag, this can prevent blocking the rendering of page content. The specific location selection may need to be balanced according to the requirements of the statistical tool and your needs for website performance.

  3. Why are you using{{- pluginJsCode|safe }}or{{自定义参数名|safe}}When, it must be added|safeThis filter? |safeThe filter is an important feature of the AnQiCMS template engine, which tells the system that the content processed by this filter is 'safe' HTML or JavaScript code and does not require automatic escaping. If it is missing|safeThe template engine will escape HTML tags (such as<script>/</>) and special characters in JavaScript code to HTML entities (such as<Will be escaped to&lt;), causing the statistics code to not be recognized by the browser as executable script, thus failing. Therefore, it is added.|safeTo ensure that the statistical code can be executed as original JavaScript by the browser.

Related articles

How can AnQi CMS use the 'time factor' feature to display future published content?

How to efficiently and strategically publish content in today's fast-paced content environment is a question that every content operator is thinking about.Maintain the consistency and foresight of content publication, which can not only enhance the user experience but also effectively promote brand communication and search engine optimization.AnQi CMS deeply understands this, and its 'Time Factor' feature was born for this very purpose, providing content creators and operation teams with a precise tool to control the timing of content release.## Precise Planning: The Foundation of Content Operation We have all faced such a situation: writing an精心 prepared article

2025-11-08

How can AnQi CMS templates inherit parent templates and rewrite specific block content to customize display?

In Anqi CMS, the template system provides a powerful and flexible mechanism that allows users to efficiently customize the layout and content display of the website.Among them, "inheriting the parent template and rewriting specific block content" is a key function to achieve personalized design and maintain consistency with the overall style of the website. ### Core Concept: Say goodbye to repetition, embrace inheritance Imagine that the header, footer, sidebar, and other elements of a website are fixed and unchanged on almost every page. If there is no template inheritance mechanism, we may need to repeat this common code in each page template, which increases the difficulty of maintenance

2025-11-08

How to truncate a long string and display an ellipsis in AnQi CMS templates?

The flexibility of content display is crucial in the template making process of Anqi CMS.When it is necessary to display a long text within a limited space, such as an article abstract, product description, or brief introduction, truncating the strings with an ellipsis is a common optimization method. It can effectively maintain the neat layout of the page and guide users to click and view the full content.AnQi CMS is developed based on Go language, its template engine syntax is similar to Django, and it provides powerful filter (filters) functions that can easily meet this requirement.### Skillfully Utilize Filters

2025-11-08

How to automatically add hyperlinks to URLs and email addresses in article content of AnQi CMS?

In content management and website operations, automatically converting URLs and email addresses in the text to clickable hyperlinks can greatly enhance user experience and optimize the internal link structure of the website to some extent.For AnQiCMS users, implementing this feature is not through simple backend settings, but through the specific "filter" provided by its powerful template engine.This design approach gives website owners great flexibility and control, allowing them to finely manage the generation of links according to the needs of different content areas.

2025-11-08

How to display the current year or time in a specific format in AnQi CMS template?

In website operation, it is a common requirement to flexibly display the current year or format specific time, whether it is the automatic update of the year in the copyright statement or the clear display of the publication time on the article detail page.AnQiCMS provides two main ways to meet these needs, they are both simple to use and follow the elegant time handling of the Go language.### Method 1: Directly retrieve and display the current year or time (`{% now %}` tag) When you need to directly retrieve and display the current year or the current time down to the second in the template

2025-11-08

How to add multi-dimensional parameter filtering function for the product list page in Anqi CMS and display the filtering results?

In modern e-commerce and content display websites, providing multi-dimensional parameter filtering functions for product lists has become a key factor in improving user experience and conversion rates.Visitors can quickly locate the products they need based on their own needs, not only saving time but also significantly improving the usability of the website.For users of AnQiCMS, implementing such a feature is not difficult. The built-in powerful functions and flexible template tags make the whole process intuitive and efficient.This article will delve into how to add multi-dimensional parameter filtering functions to the product list page in Anqi CMS

2025-11-08

How does AnQi CMS filter and display content based on the document's Flag attribute (such as headline, recommended)?

In AnQiCMS (AnQiCMS) content management system, effectively organizing and displaying content is the key to enhancing website attractiveness and user experience.Among them, the Flag attribute (recommended attribute) function of the document, as if marking the content with a special 'mark', allows you to flexibly filter and highlight important or specific types of content according to your operational needs.What is the document Flag attribute? The document Flag attribute, also known as the recommendation attribute, is a content classification and display mechanism provided by AnQi CMS.

2025-11-08

How to manage and display custom page Banner carousel in Anqi CMS?

In website operation, a beautiful page banner carousel is a key element to attract visitors' attention, convey important information, and enhance brand image.AnQiCMS provides a flexible and intuitive way to manage and display these visual contents, whether you want to set up a Banner for the homepage, a specific page, or a category page, it can be easily achieved.### Manage Custom Banner Carousel AnQi CMS allows you to set exclusive banners for different content types, mainly divided into banners for specific pages

2025-11-08