Logo of the Baidu Analytics web statistics online tracking service.
Screenshot of the Baidu Analytics tracker code page with the Web Property ID.
Baidu Analytics module Administration Settings form page.

Adds the Baidu Analytics web statistics tracking system to your website.
Baidu Analytics (百度统计 Baidu Tongji, in Chinese) is Baidu search engine's web analytics platform.

It provides users with many reports about visitors to their website, such as a report on the source of visitors, user demographics, reports on content viewed on site, a heat map, and many other features.

Features

The module allows you to add the following statistics features to your site:

  • Selectively track/exclude certain users, roles and pages
  • Monitor what type of links are tracked (downloads, outgoing and mailto)
  • Monitor what files are downloaded from your pages
  • Custom variables support with tokens
  • Custom code snippets
  • Site Search support
  • DoNotTrack support (non-cached content only)
  • Drupal messages tracking
  • Modal dialog tracking (Colorbox)
  • Access denied (403) and Page not found (404) tracking
  • Cache the Baidu Analytics code on your local server for improved page loading times

Implementation

Module's code was greatly inspired and adapted from the excellent Google Analytics module (7.x-1.x branch).
Several features provided by Google Analytics API had to be adjusted since Baidu Analytics has its own (slightly different) ways, methods and API to provide a similar set of features.
The Baidu Analytics module currently supports two types of JavaScript code for script inclusion: Standard (Legacy) and Asynchronous (Recommended), as provided on Baidu Analytics code tracker page (screenshot).

Main differences with the Google Analytics module:

  • Single/multi/cross domain tracking doesn't seem to impact changes to the code embedded and currently, Baidu Analytics doesn't seem to support _setDomainName and _setAllowLinker operations.
  • Anonymize visitors IP address had to be removed, mostly due to the lack of support for _anonymizeIp.
  • AdSense support or DoubleClick remarketing support could probably be further adapted to leverage Baidu's equivalent: Baidu Tuiguang (百度推广), and this is something that we could perhaps explore for future developments (see section below).

Overall, Tracking of 404/403, Messages/Links/Downloads, Site Search and Caching had all to be slightly adapted to match closer with Baidu Analytics' platform and API, but in general, most of Google Analytics' features could cross-over very nicely with a great amount of similarities (Some parts could even be re-used almost "as is", such as for all CustomVars, Users/Roles/DoNotTrack, Tokens, or Visibility related features).

Installation and configuration

All this information could also be found in module's README.TXT file.

1 - Download the module and copy it into your contributed modules folder:
[for example, your_drupal_path/sites/all/modules] and enable it from the modules administration/management page.
More information at: Installing contributed modules (Drupal 7).

2 - Configuration:
a. After successful installation, browse to the Baidu Analytics Settings form page under:
Home » Administration » Configuration » System » Baidu Analytics
Path: admin/config/system/baidu_analytics or use the "Configure" link displayed on the Modules management page.

To start using Baidu Analytics fill in the Web Property ID (Site Tracker ID) as described in field's help text (first field of the admin settings form). If you don't already have a Web Property ID, feel free to register your site with Baidu Analytics, or if you already have registered your site, go to your Baidu Analytics tracker code page to extract the ID inside the JavaScript code provided (screenshot). Find more information in the documentation.

b. Configure all other settings: enable/disable tracking of messages/links/search, visibility, roles, users, etc... and save the form.
Please make sure Cache is not enabled before testing that all settings work properly.

Useful Resources

For any questions and problems, you may find some help on the Baidu Analytics official site:

  1. Baidu Analytics Module Documentation.
  2. Unfortunately, there isn't much English documentation or literature on Baidu Analytics, so if you would like to know more about its Features in general, we would recommend the article: A Thorough Guide to Baidu Analytics (Baidu Tongji).
  3. Baidu Analytics Forum:
    For general discussions, inquiries, future developments or API changes, etc...
  4. Baidu Analytics Help Center and help on Baidu Tuiguang.
  5. Baidu Analytics Chinese API Documentation.

Future developments:

Module is subject to changes and restrictions from the Baidu Analytics Javascript API.

Among some of the features that could probably be supported but haven't been tested/developed yet, support for WAP tracking code could perhaps be added in the future depending on the interest and testing capabilities (see screenshot of WAP code).
As an equivalent to Google Adsense, Baidu Tuiguang (百度推广) is Baidu's online advertising service and would certainly be a feature that we would envision as part of the module at some point, but it would still need more work and testing.
Integration with Drupal Commerce/Ubertcart (order workflow), Chinese Social Networks Authentication (CSNA) or any other module could potentially be considered in the future, for tracking of orders, amounts, or pulled/pushed information from SNS platform, for example.
Currently, Cross-site browsing still seems to be provided in the backend of Baidu Analytics, and Anonymize visitors IP isn't supported at the moment, but if the API came to change in the future with the addition of _setDomainName, _setAllowLinker or _anonymizeIp operations to the API's JS framework, it would surely be great to see these features added to the module.

Lastly, efforts could be made and hopefully sustained on the overall maintenance, with improved documentation (especially in Chinese), tutorials/presentations of how module's features could be leveraged for better SEO/SEM in Chinese, module's translations, more simpletests (Automated Test Cases), more code snippets and of course the usual bug fixes.

Contributions are welcome!!

Feel free to follow up in the issue queue for any contributions, bug reports, feature requests.
Tests, feedback or comments (and of course, patches) in general are highly appreciated.

Credits

First and foremost we are particularly grateful to the Drupal community behind the Google Analytics module, their contributors (especially Alexander Hass @hass) and amazing work, without which this module would perhaps be very far from the level of maturity and supported features it has today.
Hopefully, new features, patches or tests added to this module might as well be ported/adapted to be contributed and shared back with the Google Analytics module.
Special thanks to xiukun.zhou for reviewing the project, testing and debugging.

This module was sponsored by DAVYIN | 上海戴文.

Supporting organizations: 
Development and maintenance of the module.

Project Information

Downloads