How to embed the code of third-party statistical tools (such as Baidu statistics, Google Analytics) into the Anqi CMS website?

Calendar 👁️ 84

As an experienced website operations expert, I know the value of data for the growth of the website.It cannot be separated from the in-depth analysis of access data whether it is to optimize the user experience, improve conversion rates, or formulate precise marketing strategies.AnQiCMS (AnQiCMS) took the operator's needs into full consideration from the very beginning of its design, its powerful and flexible features make it extremely easy to integrate third-party statistical tools.

Today, let's talk about how to elegantly embed the code of third-party statistics tools like Baidu Statistics and Google Analytics into your secure CMS website, so that your website can go from being 'unknown' to 'keenly aware of things'.


How to easily embed third-party statistical tool code in AnQi CMS website and insights into user behavior?

Want to fully understand the behavior track of users on your security CMS website, third-party statistical tools are undoubtedly your helpful assistant.These tools can collect and present key metrics such as visitor sources, page views, dwell time, bounce rate, and help you make data-driven decisions.Fortunately, AnQi CMS provides multiple ways for you to easily integrate these statistics codes into your website.

The powerful template engine and flexible backend settings of AnQi CMS provide us with the convenience to embed various codes.Statistical code is a JavaScript code snippet that needs to be executed on each page of your website when loaded.According to the requirements of the statistical tool, this code may need to be placed on the page.<head>Region,<body>The start or<body>End position of the.

Understanding the structure of Anqi CMS: paving the way for embedded statistical code

In AnQi CMS, the generation of website pages depends on its modular template system. All template files are stored in/templatethe directory, and.htmlsuffix. Common template files such asbash.html(usually includes the public header and footer of the website),partial/The code snippets under the directory are all areas we need to pay attention to.

The backend of Anqicms provides an intuitive and convenient configuration entry for website operators.In the 'Function Management' module, there is a dedicated area for embedding this kind of general JS code, which greatly reduces the technical threshold.

Next, I will introduce two mainstream embedding methods, whether you are pursuing simplicity and speed, or need fine-grained control, you can find a suitable solution for yourself.


Method one: Through the convenient settings of the Anqi CMS backend (recommended)

This is the most recommended and simplest method, suitable for most scenarios where it is necessary to embed statistical code globally on the website.The Anqi CMS provides a dedicated text box, allowing you to directly paste statistics code without touching any code files.

Step one: Get your statistics tool code

First, you need to log in to the backend of the third-party statistical tool you have chosen (such as Baidu Statistics, Google Analytics), find and copy the website statistical code. Usually, this will be a segment that starts with<script>Tag start and end JavaScript code block.

  • Baidu Statistics:Log in to Baidu Statistics -> Manage -> Website List -> Get Code -> Copy the entire code snippet.
  • Google Analytics (GA4):Log in to Google Analytics -> Manage -> Data Streams -> Select your Web Data Stream -> View code instructions -> Global website code (gtag.js) -> Copy the entire code snippet.

Make sure you copy the entire code block, including<script>and</script>.

Step two: Log in to the Anqi CMS management background

Log in to the admin panel of your Anqí CMS website using your admin account and password.

Step three: Find the "Link Push" feature

Click sequentially in the left navigation bar of the admin interface.“Function Management”and then select"Link Push". You will see settings such as "Baidu Search Active Push Interface",

Step four: Paste and save the statistics code

Scroll down the page and you will find a name called“360/Top News and others JS auto-submit”The text area. This area is specifically designed for this type of general JS code. Paste the statistics code you copied in step one completely into this text box.

After pasting, please be sure to click the bottom of the page.“Save”Button. AnQi CMS will save this code in the database and automatically inject it into the website page during each page rendering. The template rendering of AnQi CMS will call{{- pluginJsCode|safe }}This label (based on the documenttag-tongji.mdas stated), ensure that your code is safely output to the frontend.

Step five: Clear the cache and verify the effect

To ensure that the changes take effect immediately, please click on the left navigation bar in the background.“Update Cache”.

Then, open your website's frontend page. You can verify that the code has been successfully embedded in the following way:

  1. Browser Developer Tools: PressF12Press the key to open the browser developer tools, switch to the "Elements" or "Sources" tab. Search for the unique string in your statistics code snippet (such asanalytics.js/gtag.jsOr Baidu Statisticshm.js), see if it appears on the page<head>or<body>Tag inside.
  2. Statistical tool auxiliary plugin:Install Google Tag Assistant for Chrome or Baidu Statistics Debugger and other browser plugins, which can help you detect the statistics code running on your website.

Method two: Directly modify the template file (suitable for advanced users and special needs)

If you have a finer control requirement for the code, such as embedding it only on specific pages, needing to place it at a specific position on the page, or if your analytics tool code requires strict placement, then directly modifying the template file would be a more flexible option.

Step 1: Locate the appropriate template file

The template files of AnQi CMS are usually located/template/您的主题名称/in the directory. You need to find the most suitable template file according to the placement requirements of the statistical code:

  • Global header:The most common is the theme directory under:bash.htmlOrpartial/header.htmlThis type of file. It is usually used to place<head>the code within the area.
  • Global bottom: bash.htmlat the bottom, orpartial/footer.htmlThis type of file. It is usually used to place<body>the code before the end tag, which helps improve page loading performance.
  • Specific Page:If it is only embedded on the homepage, article detail page, or a specific single page, you need to find the correspondingindex.html/{模型table}/detail.htmlorpage/detail.htmletc. files.

Step 2: Online Template Editing

Log in to the Anqi CMS backend, click the left-hand navigation bar's“Template Design”and then select“Website Template Management”. Here, you can directly edit your theme template files online.

Step three: Paste the statistical code carefully

Open the template file you are sure to modify. Paste the code into the corresponding position according to the requirements of the statistical tool.

  • in<head>Inside the tag:Find<head>and</head>Paste the code between them.
  • in<body>Before the closing tag:Find</body>Before the label, paste the code.

Please note that the statistical code is standard JavaScript code and usually does not conflict with the Django-like template syntax of AnQi CMS. Paste it directly without any modification.{% raw %}or{% endraw %}tag wrapping.

Step 4: Save and verify the effect

After pasting the code, click the bottom of the page“Save”button. Similarly, go to the left navigation bar in the background and click“Update Cache”.

Finally, as in Method 1, verify that the statistical code has been activated on your website page by using browser developer tools or auxiliary plugins for statistical tools.


Operation expert's reminder: Ensure the statistics are accurate and error-free

No matter which embedding method you choose, these suggestions will help you better manage and utilize the statistics:

  1. Consideration of code placement:Most statistical tools recommend placing the code in<head>Within tags, to ensure that data can be captured at the beginning of page loading. However, when considering the page rendering performance, some non-critical tracking code can also be placed in</body>Before the end tag.
  2. The importance of caching:In Anqi CMS, any modifications to the background configuration or template files are recommended to clear the cache in a timely manner to ensure that the latest content is loaded on the front-end page.
  3. Regularly check:

Related articles

What type of tracking code is specifically referred to by the 'Statistics Code Tag' in Anqi CMS?

## The "Statistics Code Tag" of AnQi CMS: An Intelligent Carrier for Operation Insight and Flexible Integration In the wave of digitalization, website operation is like sailing, data is the compass, guiding us through the market fog and towards the shore of success.For AnQiCMS users, efficiently integrating and utilizing statistical tools is the foundation for precise content marketing and SEO optimization.When we talk about the 'statistical code tag' of AnQiCMS, we are actually discussing a highly flexible and meaningful integration mechanism, which is more than just a few lines of code

2025-11-07

Where is the actual output position of the TDK tag of AnQi CMS on the front-end page?

As an experienced website operations expert, I know that TDK (Title, Description, Keywords) tags play a crucial role in the performance of a website in search engines.It is not only the 'business card' of the page, but also a key element to guide search engines to understand the page topic and attract users to click.In AnQiCMS (AnQiCMS) such a content management system that focuses on SEO optimization, the output position and management mechanism of TDK tags are the core knowledge that every operator needs to deeply master.

2025-11-07

What is the impact of not setting the variable name when calling the `tdk` tag in AnQi CMS?

## SecurityCMS `tdk` tag: Are you really using it correctly without a variable name?As an experienced website operator, we are well aware that every detail of the website can affect user experience and search engine optimization (SEO) effects.In AnQiCMS (AnQiCMS) such an efficient and powerful content management system, the flexible use of template tags is the key to improving operational efficiency.

2025-11-07

How can A/B testing of different TDK tags be implemented in AnQi CMS?

## Explore AnQi CMS: How to cleverly use existing features to achieve A/B test effect evaluation of TDK tags As an experienced website operation expert, we know that in the highly competitive network world, every detail may affect the final performance of the website. Among them, the "TDK" three major tags, such as Title (title), Description (description), and Keywords (keywords), although simple in appearance, are the foundation of search engine optimization (SEO), directly related to the visibility and click-through rate of the website in search results.

2025-11-07

What is the special meaning of the usage of 'statistical code tag' in the template's `{{- pluginJsCode|safe }}`?

In the vast realm of website operation, data is like stars on a nautical chart, guiding us in the direction of our journey.In order to collect this valuable data, the deployment of statistical code is particularly critical.As an experienced user and operation expert of AnQiCMS, I am well aware of its powerful and flexible template mechanism.

2025-11-07

Why is it considered to use the `|safe` filter when calling the “Code Tag Statistics” function? Is there any security risk?

## SecureCMS: Unveiling the `|safe` filter in statistics code tags, considerations for security and risk avoidance As an experienced website operations expert, I am well aware that in modern content management, it is often necessary to find a delicate balance between flexibility and security.AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language. From the very beginning of its design, it has attached great importance to the system's performance, customizability, and security, aiming to provide users with a stable and efficient content management solution.

2025-11-07

Does Anqi CMS have a built-in statistical code management feature for easy addition and modification?

In the daily operation of websites, the management of statistical codes is often a headache.Whether it is Google Analytics, Baidu Statistics, or various ad monitoring codes, they all need to be placed accurately at specific locations on the website.If you have to manually edit code files every time you add, modify, or change a template, it is not only inefficient but also prone to errors.Then, for AnQiCMS such a content management system known for its efficiency and ease of use, is it built-in with statistical code management functions, which can conveniently allow us to add and modify them uniformly?The answer is affirmative

2025-11-07

How can I add statistical code to a specific page instead of the entire site in Anqi CMS?

## Fine-grained operation: How does Anqi CMS customize statistics code for specific pages In daily website operation, we often encounter such needs: not all pages need to load the same statistics code.Maybe it is to track the conversion of a certain promotional activity more accurately, or to conduct A/B testing on the user behavior of a specific product page, or to load specific third-party service code on some important pages.

2025-11-07