Purpose
Problem
User wants to add Baidu Analytics tracking to their STK website. Baidu Analytics is the equivalent of Google Analytics in China.
Administrators of websites in China may prefer Baidu Analytics to Google Analytics because:
- It may be more familiar to Chinese website administrators.
- It is integrated with other Baidu services such as their advertising platform that the administrator uses.
- Google is sometimes blocked in China which can make Google Analytics inaccurate for websites hosted in China.
Goals
For each STK site, the user can easily enable and disable Baidu Analytics tracking for all pages of the site by specifying the Baidu tracking ID and setting an enable flag.
Use Cases
Since Google Analytics and Baidu Analytics are similar in functionality, and there is already a Google Analytics module, we will try to match the user experience for the Baidu Analytics module to the Google Analytics module wherever that makes sense.
Installation
After installation, Configuration:/modules/baidu-analytics/config/sites/
will be nodes corresponding to sites of the same name as defined in Site Definitions
.
Each node in Configuration:/modules/baidu-analytics/config/sites/
will contain two properties enabled
and trackerID
.
Configuration:/modules/baidu-analytics/config/sites/
will contain two nodes after installation, a site
node for the default CE site and a default
node for the default EE site. The enabled
properties of both nodes will be set to false
and the trackerID
property of both nodes will not be set.
Enable Baidu Analytics tracking for all pages of a site
A user enables standard Baidu Analytics page tracking for all pages of a site by creating a node in Configuration:/modules/baidu-analytics/config/sites/
with the same name as the site defined in Site Definitions
and setting its enabled
property to true
and setting its trackerID
property to the ID provided by Baidu Analytics.
Disable Baidu Analytics tracking for all pages of a site
A user disables standard Baidu Analytics page tracking for all pages of a site by either setting the enabled property of the node in Configuration:/modules/baidu-analytics/config/sites/
with the same name as the site defined in Site Definitions
to false
or deleting the node in Configuration:/modules/baidu-analytics/config/sites/
with the same name as the site defined in Site Definitions
altogether.
Proposal
Design
Standard Baidu Analytics page tracking for all pages of a site is enabled if and only if there is a node in Configuration:/modules/baidu-analytics/config/sites/
with the same name as the site defined in Site Definitions
and its enabled
property is set to true
and its trackerID
property is set to a valid ID provided by Baidu Analytics.
Questions
What if the trackerID is set but set incorrectly?
What if the website temporarily cannot connect to Baidu Analytics?
Testing
Do not forget to test using the mobile theme on mobile.
Do not forget to test what happens if page cannot connect to Baidu Analytics.
Do not forget to test what happens if trackerID
is set incorrectly.
Do not forget to test over TLS/SSL.
Future Enhancements
Asynchronous loading so that page loading is not blocked if Baidu is not available.
Events tracking configuration, similar to Google Analytics module.
Philipp's suggestions:
- Add an action to Pages in the details sub-app for a page to open the Baidu Analytics report for that page in a new Browser tab.
- Improve the above so that the Baidu Analytics report opens in a subapp, perhaps using an iFrame, possibly in a Baidu Analytics App.
- Have a Baidu Analytics App for configuring Baidu related site information and possibly displaying Baidu Analytics sourced from Baidu.
Questions
To display data from Baidu, I suspect the user will need to save their login information in the CMS. What is the best way to do this securely?
Related
Google Analytics Module