Problem:
Currently, when caching is enabled, the cached file, downloaded from Baidu Analytics' server through the URL http://hm.baidu.com/h.js or http://hm.baidu.com/hm.js, to the site's files directory, seems to actually download and save the files with the following names: h.js or hm.js, depending on the tracking code type configured.
The problem, is that unlike Google Analytics, Baidu Analytics actually includes the Web Property ID in the tracking library JavaScript code.
As explained in module's documentation at How to change the Web Property ID per hostname / domain / language, if we were to imagine using several tracking codes, for example with the Variable API module, or overrides of the $conf variable with a code snippet in the settings.php file, then, the site would be configured with multiple tracking codes.
In this case, if caching is enabled, all the different sites and configurations would be sharing the same tracking code cached file (which includes the Web Property ID), which would't work (or just for one site/Web Property ID), since only a single Web Property ID would be available in cached file. Each time the cache file would be generated for a specific tracker code (per domain, URL or site, for example), it would then overwrite the cache file of all other trackers.
In short, for Baidu Analytics, the library tracking JavaScript code seems to be associated with a single Web Property ID.
To implement this feature, we could for example, save cached files with a Tracker specific file name, for example with a hash of 7 digits from the Web Property ID, which would give: 0124abc-h.js, 0124abc-hm.js, and each tracker could have its own JavaScript cache file (with its Web Property ID in the file).
This feature would allow Caching support for a dynamic Web Property ID per hostname, domain or language.
Please let me know if you would have any questions, objections, comments, suggestions, recommendations or concerns on any aspects of this feature request, I would be glad to provide more information or explain in more details.
Any questions, feedback, testing, changes, ideas or recommendations would be highly appreciated.
Thanks to all in advance.
Comments
Comment #1
dydave commentedQuick follow-up on this feature request:
Modified the destination file names of the cached library tracking JavaScript code, as suggested in the issue summary.
Files would now be saved as:
0124abc-h.js,0124abc-hm.js, allowing multiple Web Property IDs with different code types to be cached properly in different files.Baidu Analytics' library tracking JavaScript code file name is prefixed with a hash of 7 digits from the Web Property ID.
Added short inline comment in code to explain what this hash code could be used for.
I went ahead and committed the changes against the 7.x-1.x branch at 4f953f5.
I allowed myself to mark this issue as fixed for now, but feel free to re-open it, or post a new ticket, at any time if you have any further objections with this ticket or related commit 4f953f5 (we would surely be happy to hear your feedback).
Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on the commit or this feature request in general, I would be glad to provide more information or explain in more details.
Thanks in advance to everyone for your testing, reviews, feedback and comments on this issue.
Cheers!