Currently, module only allows Header or Footer to be selected for the JavaScript scope.
However, it seems that Baidu Analytics would recommend the code to be in different scopes depending on the type of code selected:
- Standard code is recommended to be inserted in the footer region of the page right before
</body>closing tag. - Asynchronous code is recommended to be inserted in the header region of the page right before
</head>closing tag.
Currently, user has to manually select the correct Javascript scope, between footer and header, depending on the type of code selected (Asynchronous or Standard), which might create some issues for some users.
Ideally, we could add a default Javascript scope option to be selected in the drop-down among, header and footer.
Then a if statement could check if the default value would have been selected as the scope, in which case generated JavaScipt code would be inserted in the appropriate scope (whether header or footer) depending on the type of code configured (Asynchronous by default, or Standard).
In this case users would still be able to select to override the default/recommended settings by configuring a fixed value: header or footer (as it is already the case currently), or leave the default value which would automatically select the scope based on Baidu Analytics' recommendations.
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:
Added a new Default option in the dropdown field JavaScript scope to provide the logic detailed in the issue summary.

JavaScript scope defaults to default.
Greatly improved field's description, to clearly explain what Baidu Analytics would currently recommend for the scope of each one of the code types:
Modified
baidu_analytics.modulefile'sbaidu_analytics_page_alterto add aifstatement, as described in the issue summary, to select the recommended default scope depending on the type of code configured, see baidu_analytics.module-commit-1810665-diff.I went ahead and committed the changes against the 7.x-1.x branch at 1810665, followed by another commit at 3ff4c24 to improve the description of the JavaScript scope field for the default value added in previous commit.
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 any of the related commits (1810665, 3ff4c24 - 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 commits 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!