As website operators, we often need to adjust or replace the statistical code used on the website based on business development and data analysis needs.Whether it is to migrate from the old statistical platform to the new platform, or to introduce more refined data tracking, this process requires us to complete the switch efficiently and smoothly, avoiding any interference with the normal operation of the website.
At the initial design of Anqi CMS, great consideration was given to the flexibility of operation, providing a very convenient 'Statistics Code Tag' feature, making it extremely simple and safe to replace existing statistics codes.Let's take a look at how to smoothly switch the statistics code using this feature.
Understand the 'Statistics Code Tag' of Anqi CMS
There will be a preset 'Statistics Code Tag' within the system (i.e.,{{- pluginJsCode|safe }}It will automatically insert any JS code you enter in this background setting box, safely and completely, into the corresponding position of the website (usually the page's<head>or<body>Label within), ensure that the code can be correctly loaded and executed.The benefits of this design are that you do not need to directly modify any template files, all code management is done in the background, which greatly reduces the technical threshold and risk of error in operation.
Smooth transition of statistical code steps
When you need to replace the statistical code on the website, Anqi CMS provides the following simple and intuitive steps:
Obtain the new statistical code:Firstly, you need to go to the new statistics platform (such as Google Analytics 4, Baidu statistics, etc.), find and copy the complete JavaScript statistics code provided. Make sure that the copied code is complete, it usually contains
<script>and</script>Label.Login to the CMS backend, locate the settings entry: Enter your security CMS backend management interface. Find and click on "Function Management
Replace old code, paste new code:On the "Link PushThis text box should currently contain the statistics code that your website is using. To smoothly switch, simply delete all the existing statistical code in this text box and then paste the new statistical code you copied in step one completely.
<script>and</script>Label.Save settings and update cache:After pasting the new code, be sure to click the "Save" or "Submit" button at the bottom of the page to make the changes take effect.To ensure that the website front-end can immediately load the new statistical code, it is recommended that you click on the "Update Cache" feature in the left navigation bar and clear the website's cache.This allows the latest configuration to take effect immediately.
Verify if the statistical code is working:Complete the above steps, then open your website's frontend page, and use the browser's developer tools (usually F12), to view the page source or network requests.
- View source code:Search for the characteristic string of the statistics code you have just pasted, to see if it has already appeared in the page's HTML.
- View network requests:In the Network tab of the developer tools, filter JS files, and you can usually see the loading requests for statistical scripts (such as
analytics.js/gtag.jsorhm.jsetc). - Use real-time reports from the statistical platform:Log in to the backend of the new statistics platform to view the real-time report feature.If you can see that there are visitors browsing your website (that is, yourself), it means that the new statistics code has been successfully installed and is now working.
Why is this switching method smooth and efficient?
The "Statistics Code Tag" feature of the A safe CMS can achieve smooth and efficient switching mainly due to its core advantages:
- No need to touch the template file:You do not need to open an FTP client, nor do you need to face complex HTML/Twig template code; all operations are completed in the intuitive backend interface, which greatly reduces the risk of misoperation.
- One-click full-site update:Once you replace the code in the background and save, the Safe CMS can ensure that this new statistical code takes effect on all pages of your website without having to modify each page individually.
- Centralized management, clear and concise:All statistical codes are managed in one place, making it quick to find the corresponding locations for auditing, modification, or removal, thus avoiding the difficulty of maintaining scattered codes.
- Respond quickly to operational changes:Whether it is the change in data analysis requirements or the need to deploy new tracking codes urgently for market activities, this centralized management can allow you to respond quickly and ensure the continuity of data tracking.
Through this way, even if you are not very familiar with programming and website development, you can easily manage and replace the statistical code of the website, making your content operation and data analysis work smoother.
Common Questions (FAQ)
Q1: Can I paste two different statistical codes (such as Baidu Statistics and Google Analytics) at the same time in the "JS Automatic Submission" box?Of course, you can.You only need to paste the two statistical codes in sequence into the text box of '360/Toutiao and other JS automatic submission'.The "Statistics Code Tag" of AnQi CMS will insert them all into the web page in the order you paste.<script>Label.
Q2: If I only want to use a certain statistic code on a specific page and not throughout the entire site, can Anqi CMS achieve this?The "Statistics Code Tag" of AnQi CMS is mainly used for the general statistics code of the entire website.If you have fine-grained statistics needs at the page level, such as loading special code only on certain activity pages or excluding certain pages from loading common code, this usually requires deeper template editing.You can make conditional judgments based on the current page ID, category ID, or other identifiers in the template file, and then manually insert or exclude specific code.Of course, this requires some knowledge of template development.
Q3: Why do I not see the new code on the front-end page even though I replaced the tracking code and cleared the cache?There could be several reasons:
- Browser cache:
- CDN Cache:If your website uses a CDN service, the CDN node may have cached old pages. You need to log in to the CDN service provider's backend and manually refresh the entire site cache.
- Code error: The newly pasted statistics code may contain syntax errors or be incomplete, causing it to fail to load properly. Please carefully check whether the code you copied from the statistics platform is complete and correct.
- Back-end save not effective:Please confirm that you have saved the changes in the AnQi CMS back-end, and the system prompts that the save was successful. Sometimes network problems can cause the save to fail.