Two methods for adding statistics code to WordPress

Source: Internet
Author: User


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,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.