AnQiCMS 中 flexible control of statistics code: No need to modify the template, easily turn on and off in the background

In modern website operations, statistical codes (such as Baidu Analytics, Google Analytics, CNZZ, etc.) are indispensable tools, which help us understand user behavior and optimize website performance.However, frequently modifying template files to add, update, or remove this code is not only inefficient but may also introduce errors due to operational mistakes.Auto CMS (AutoCMS) fully considers this user requirement and provides a convenient way to dynamically manage statistical codes without directly editing template files.

Unveiling the core mechanism: The 'magic placeholder' in the template and the linkage with the background configuration

The ability to achieve this feature is attributed to Anqi CMS's flexible template tag design and powerful backend management system.In the template files of AnQi CMS, there is usually a placeholder reserved specifically for inserting such JavaScript code.{{- pluginJsCode|safe }}.

This label plays a crucial role:

  • pluginJsCode: It is a variable, its content comes from the specific settings of the AnQi CMS backend.
  • |safe: It is a filter, it tells the template engine,pluginJsCode
  • {{- ... }}This is used for removing the whitespace characters of the line where the tag is located.-The symbol is used to remove the whitespace characters of the line where the tag is located, making the final output code more tidy.

When the page is accessed, Safe CMS will checkpluginJsCodeIs there content in the variable.If it exists, it will be inserted completely into the page; if it is empty, no code will be output.This variable's content is completely determined by your backend configuration, thus realizing dynamic control.

Specific operation steps: Three steps to easily manage statistical code

To dynamically turn on or off the website's statistical code, the operation process is very intuitive:

Step 1: Log in to the background and locate the feature entry

Firstly, you need to log in to the backend of your security CMS website. Find and click on the“Function Management”in the expanded feature list."Link Push".

第二步:Find the '360/头条等JS自动提交' setting item

In the "Link PushAlthough the name mentions 360 and Toutiao, this text box is actually generic, and you can paste any JavaScript statistics code or third-party script that needs to be globally loaded here.

第三步:Paste or clear the code, and implement dynamic control

  • Enable statistics code: Translate the content from 'auto' to 'English' while maintaining the original JSON array format.Make sure to include the complete<script>and</script>tagsPaste it into this text box. After pasting, click save. Your website's frontend page will automatically load this statistics code.
  • Close statistics code:If you want to temporarily disable or completely remove the statistics code, just clear all the content in this text box.Clear and then click Save.The website front-end page will no longer load any statistical code.

Through this method, you can always operate on the background interface without the need for FTP tools, nor do you need to manually modify any template files.

Why is it so convenient? The design philosophy of AnQiCMS

Auto CMS is dedicated to providing efficient, customizable and easy-to-manage content solutions. This statistical code management method is a reflection of its 'usability' and 'flexibility':

  • Lower technical threshold:Website operators do not need to have front-end development knowledge and can easily manage key code.
  • Improve operational efficiency:Quickly respond to changes in statistical requirements, such as temporarily closing a section of code for testing, or switching statistical scripts during different marketing activities.
  • Ensure system security and stability:Avoided syntax errors or code conflicts that may be introduced due to manual modification of template files, keeping the website running more stably.
  • Centralized management:All third-party scripts are managed in one place, which is convenient for auditing and maintenance.

Useful tips and注意事项

  1. Make sure to include the complete one<script>Tags:The JavaScript code snippet you paste must end with<script>Start, with</script>, otherwise the code will not execute normally.
  2. Update the cache in a timely manner:After modifying and saving the code in the background, it is recommended to go to the 'Update Cache' feature to clear the website cache to ensure that the front-end page can immediately load the latest code settings.
  3. Code placement location:The template design of Anqi CMS determines{{- pluginJsCode|safe }}the actual output position of labels. Usually, statistical code is placed in</body>before the<head>Label within. If you have specific requirements for the loading order or position of the code, you may need to consult your template file.pluginJsCodeLabel's specific embedding point. However, for most general statistical codes, the default insertion position is sufficient.
  4. Test verification:After changing the statistical code, be sure to visit the front-end page of the website, and use the browser's developer tools (F12) to check network requests and console logs to confirm that the statistical code is loaded and executed correctly.

Through the functionality provided by the Anqi CMS, you can simply manage the statistical code of the website just like managing article content, making the operation of the website more relaxed and efficient.


Common Questions (FAQ)

Q1:This feature can only be used for the statistics code of 360 and Toutiao?

A1:No.Although the name of the function entry is "360/Toutiao and other JS automatic submission", this is just a sample naming.In fact, you can paste any third-party statistics, monitoring, advertising placement, and other JavaScript code that needs to be globally loaded (such as Baidu statistics, Google Analytics, Tencent analysis, website customer service, etc.) into this text box.It is a generic JavaScript code insertion point.

Q2:What if I need to insert multiple segments of statistics code? Can I paste them all in one text box?

A2:Absolutely.If you have multiple statistics or third-party JS code to insert, just paste them one by one in the required loading order into this '360/Toutiao and other JS automatic submission' text box.<script>and</script>Label. The Safe CMS will output these codes to the front-end page according to the order you paste.

Q3: Where will the statistics code be inserted into the page? It is<head>Or<body>before the end?

A3: This depends on the specific design of the AnQiCMS template you are currently using. Usually, AnQiCMS will place{{- pluginJsCode|safe }}This tag in the template file.</body>Before the end tag, or<head>Within the tag. If you have special requirements for the precise insertion position of the code, it is recommended to refer to thebase.htmlor public header/footer files, findpluginJsCodeThe exact position of the label. It is a good choice before for most statistical codes.</body>It is a good choice before for compatibility.