Get Statistics Code
I usually use Baidu statistics, so here we take Baidu statistics as an example.
To obtain the statistical code, follow these steps:
1. Register a Baidu account
2. Add and verify the website
3. Verification passed
4. Disable the display of statistical charts (depending on your preferences)
5. Get the code. You can select synchronous or asynchronous code. Asynchronous code may not be able to check whether the code is correctly installed through Baidu's built-in code installation check.
Modify webpage code and add Statistics Code
There are two ways to directly modify the footer. Php file,
Or you can add a function to your functions. Php file and mount it to also called.
The following is a demonstration:
Modify the footer. Php file to add statistics code
Locate the tag location in the footer File (footer. php) and add the statistical code you obtained before it.
Add a function to functions. php and mount it to the footer for execution.
Add the following code to the end of functions. php:
| The code is as follows: |
Copy code |
Function add_tj_code () {?> // Add your Statistics Code here <? Php} |
Add_action
Add Statistics code to the gadgets
This is the simplest method, but it is also the most efficient method,
Because gadgets are generally in the sidebar of the page, the loading of statistics code is pushed to the middle of page loading,
It will have a certain impact on the page loading speed, and it is not very beautiful. The following describes the method.
In the dashboard-> Appearance-> Gadgets, drag the text gadgets to the gadgets area,
As shown in the following figure, the statistics code is added to the red box,