没有不值得去解决的问题,也没有不值得去学习的技术!

After the WordPress English site is migrated from /en/ to a subdomain, how to adjust GA4 and Baidu statistics

【图 1,终端检查 www 与 en 域名统计代码的结果】

Recently, I moved the WordPress English site from the original subdirectory:

Plaintext
https://www.shuijingwanwq.com/en/

Migrated to a separate subdomain:

Plaintext
https://en.shuijingwanwq.com/

Search engine-related site maps, 301 jumps, Google Search Console and Baidu Search resource platforms have been adjusted, but access statistics still need to be checked separately.

After the actual processing this time, it was found that the adjustment ideas of Google Analytics 4 and Baidu statistics are not the same.:

  • GA4 does not need to recreate attributes or data streams, but needs to adjust the default presentation dimension of the report;
  • Baidu statistics does not need to re-add websites, but it is recommended to increase cross-domain monitoring;
  • Both platforms should continue to use the original statistical code;
  • The historical data before and after the migration will not be automatically merged, and it needs to be distinguished by the domain name or the full URL.

This article records the complete inspection and adjustment process.


1. Statistical structure after migration

Before the migration, both the Chinese and English stations were located in the same domain name:

Plaintext
中文站:
https://www.shuijingwanwq.com/

英文站:
https://www.shuijingwanwq.com/en/

After the migration, the website structure becomes:

Plaintext
中文站:
https://www.shuijingwanwq.com/

英文站:
https://en.shuijingwanwq.com/

This change seems to just change the /en/ path to the en subdomain, but for access statistics, the identification method of the page has changed.

For example, the English article before the migration may be:

Plaintext
https://www.shuijingwanwq.com/en/2026/07/05/18871/

After migration, it becomes:

Plaintext
https://en.shuijingwanwq.com/2026/07/05/18871/

If the statistical report only shows the page path, then the migrated Chinese and English articles may be displayed as both:

Plaintext
/2026/07/05/18871/

At this time, just looking at the path, it is impossible to determine whether the data belongs to www or en.


2. First check whether the two domain names are loaded with the same statistical code

Before adjusting the statistics background, you must first confirm whether the statistics codes actually loaded by the two domain names are the same.

I executed the following command in the local terminal:

Bash
for u in \
"https://www.shuijingwanwq.com/" \
"https://en.shuijingwanwq.com/"
do
    echo
    echo "========== $u =========="

    curl -sL "$u" |
    grep -Eo 'G-[A-Z0-9]+|googletagmanager\.com/gtag/js\?id=[^"&<]+|hm\.baidu\.com/hm\.js\?[a-f0-9]+' |
    sort -u
done

The returned result is as follows:

Plaintext
========== https://www.shuijingwanwq.com/ ==========
G-89CMTD9395
googletagmanager.com/gtag/js?id=G-89CMTD9395
hm.baidu.com/hm.js?abd646c01c6bac23ff98b9f3b12c32f1

========== https://en.shuijingwanwq.com/ ==========
G-89CMTD9395
googletagmanager.com/gtag/js?id=G-89CMTD9395
hm.baidu.com/hm.js?abd646c01c6bac23ff98b9f3b12c32f1

Result description:

  • Two domain names use the same GA4 measurement ID;
  • The two domain names use the same Baidu statistics code;
  • There is no missing statistical code after the migration of the English station;
  • There is no need to recreate the statistics item.
[Figure 1, the result of the terminal checking the statistical codes of www and en domain names]
[Figure 1, the result of the terminal checking the statistical codes of www and en domain names]

3. Does Google Analytics 4 need to recreate the data stream?

The answer is no need.

www.shuijingwanwq.com with en. shuijingwanwq. com all belong to the same root domain name:

Plaintext
shuijingwanwq.com

The two subdomains can continue to use the same GA4 measurement ID.

Therefore, this migration is not required:

  • Create a new GA4 attribute;
  • Create a new Web data stream;
  • Change the measurement ID;
  • Split the data of the English station into another set of statistics.

The website url filled in in the GA4 data stream is not a strict whitelist for data collection. As long as the page loads the same metric ID correctly, the data can continue to be sent to the current attribute.


4. Why is the original GA4 report inconvenient to view?

What I was mainly looking at was:

Report → Interactivity → Web Pages and screens

The default dimension is:

Plaintext
网页路径和屏幕类

This dimension only shows the path, not the domain name.

For example:

Plaintext
/

or:

Plaintext
/2026/07/11/19327/

Before the migration, the English page was prefixed with /en/ , so it could be recognized from the path.:

Plaintext
/en/2026/07/11/19327/

After the migration, the English station is located in a separate subdomain, and the /en/ in the path has disappeared.

so:

Plaintext
https://en.shuijingwanwq.com/2026/07/11/19327/

with:

Plaintext
https://en.shuijingwanwq.com/2026/07/11/19327/

It may appear as in the ”Webpage Path’ report:

Plaintext
/2026/07/11/19327/

If there is the same path under the two domain names, the data may also be aggregated into the same row.

[Figure 2, GA4 web pages and screen reports only display the path of the web page by default]
[Figure 2, GA4 web pages and screen reports only display the path of the web page by default]

5. Temporarily add the ”host name’ sub-dimension

In order to confirm whether the data of the English domain name is collected normally, you can first click the blue plus sign next to the main dimension in the “Web Page and Screen” report.:

Plaintext
网页路径和屏幕类  +

Then search and add:

Plaintext
主机名

After adding, the report will be displayed at the same time:

Plaintext
网页路径                     主机名
/                            www.shuijingwanwq.com
/                            en.shuijingwanwq.com
/2026/07/11/19327/           en.shuijingwanwq.com

In this way, it is possible to directly determine whether a record belongs to a Chinese station or an English station.

[Figure 3, Add a host name secondary dimension to the GA4 web page and screen report]
[Figure 3, Add a host name secondary dimension to the GA4 web page and screen report]

Then enter in the search box at the top of the form:

Plaintext
en.shuijingwanwq.com

At that time, the data of English subdomains could be filtered out normally.

The verification data after the migration includes:

Plaintext
浏览次数:170
活跃用户:91
每位活跃用户浏览量:1.87
平均互动时长:17 秒
事件数:471

The data curve mainly begins to appear after the migration of the English site is completed, which is basically the same as the actual migration time.

This shows that:

  • GA4 has recognized English subdomains normally;
  • There are no statistics missing from the English station;
  • The same measurement ID can count two subdomains at the same time.
[Figure 4, using host name filtering en.shuijingwanwq.com Post-GA4 data】

However, the ”host name’ as a secondary dimension is usually only temporarily viewed, and there is no guarantee that it will be automatically retained every time the report is opened.

Therefore, the default dimensions of the report need to be further modified.


6. Set ”Web page location’ as the default GA4 dimension

For the current multi-subdomain structure, the dimension that is more suitable than “Web page path” is:

Plaintext
网页位置

‘Webpage Location” will display the full URL, for example:

Plaintext
https://www.shuijingwanwq.com/
Plaintext
https://en.shuijingwanwq.com/2026/05/01/9763/
Plaintext
https://en.shuijingwanwq.com/2026/07/11/19327/

In this way, there is no need to add an additional “host name”, and you can directly determine which domain name the data belongs to from the URL.


7. Customize the ”Web page and Screen’ report

enter:

Report → Interactivity → Web Pages and screens

Click the pencil icon in the upper right corner of the page to enter “Custom Report”.

[Figure 5, click the customize button in the upper right corner of the GA4 webpage and screen report]
[Figure 5, click the customize button in the upper right corner of the GA4 webpage and screen report]

Click on ‘Report Data” on the right:

Plaintext
尺寸

The main dimensions originally included in the current report include:

  • Page title and screen type;
  • Web page path and screen class;
  • Page title and screen name;
  • Content group.

click:

Plaintext
添加维度

Then search and add:

Plaintext
网页位置
[Figure 6, add the location of the web page to the GA4 report dimension]
[Figure 6, add the location of the web page to the GA4 report dimension]

After adding, click the three dots on the right side of ”Page Location’ to set it to:

Plaintext
默认

Click on the lower right corner:

Plaintext
应用

Finally, click “Save” at the top of the page and select:

Plaintext
将更改保存到当前报告

Do not select ”Save as New Report“, otherwise the original ”Web and Screen’ report will not be directly replaced.

[Figure 8, save the changes to the current web page and screen report]
[Figure 8, save the changes to the current web page and screen report]

After saving, the report name in the left menu becomes:

Plaintext
网页和屏幕:网页位置

The table displays the full URL by default.

[Figure 9, the GA4 web page and screen report display the complete web page location by default]
[Figure 9, the GA4 web page and screen report display the complete web page location by default]

8. GA4 historical data will not be automatically migrated

It should be noted that GA4 will not automatically modify the previously collected data because the website has made a 301 jump.

The data of the English station before the migration will still be retained as:

Plaintext
主机名:
www.shuijingwanwq.com

网页路径:
/en/...

The data of the English station after the migration will be recorded as:

Plaintext
主机名:
en.shuijingwanwq.com

网页路径:
/...

These two pieces of data belong to different time stages, and GA4 will not be automatically merged or rewritten.

Therefore, when analyzing long-term trends, it is necessary to clarify the migration date and understand the URL structure before and after the migration separately.


9. The ”Web page location’ dimension needs to pay attention to the query parameters

Although ”Web page location’ can directly display the full domain name, it may also contain URL query parameters.

For example:

Plaintext
https://www.shuijingwanwq.com/article/

with:

Plaintext
https://www.shuijingwanwq.com/article/?utm_source=test

It may be counted as two different records.

But for my current needs, the first thing to be solved is to distinguish:

Plaintext
www.shuijingwanwq.com

and:

Plaintext
en.shuijingwanwq.com

Therefore, setting ”Web page location’ as the default dimension is still the most intuitive solution.


10. Baidu statistics does not need to create a new English website

After the GA4 adjustment is completed, check Baidu statistics next.

The two domain names have been confirmed to load the same Baidu statistics code:

Plaintext
abd646c01c6bac23ff98b9f3b12c32f1

So no need:

  • Create a new English station statistics project;
  • Generate a new Baidu statistics code for English sites;
  • Delete the original statistics site;
  • Split the Chinese station and the English station into two sets of Baidu statistics.

The two domain names can continue to be classified into the same site statistics.


11. Add Baidu statistics cross-domain monitoring for English subdomains

After entering the Baidu statistics background, open:

Usage Settings → Rule Settings → Cross-domain monitoring

Fill in “Enter Domain Name’:

Plaintext
en.shuijingwanwq.com

No need to add when filling in:

Plaintext
https://

Don’t need the end either:

Plaintext
/

Then click:

Plaintext
添加

After the addition is successful, the list of “Website domain names that have been set up for cross-domain monitoring” will appear:

Plaintext
en.shuijingwanwq.com
[Figure 10, added to Baidu statistics cross-domain monitoring en.shuijingwanwq.com 】
[Figure 10, added to Baidu statistics cross-domain monitoring en.shuijingwanwq.com 】

Cross-domain monitoring is mainly used to help Baidu statistically identify users’ continuous visits between two domain names.

For example, a user clicks on the language switch from the Chinese site to enter the English site.:

Plaintext
www.shuijingwanwq.com

en.shuijingwanwq.com

After configuring cross-domain monitoring, Baidu statistics will try to identify it as the same continuous visit, rather than completely splitting it into two unrelated access processes.

This setting mainly affects the data generated after the addition, and will not go back to recalculate the previous statistical results.


12. Distinguish Baidu statistics through ‘Surveyed domain names”

After adding cross-domain monitoring, go back to Baidu statistics:

Overview → Access Analysis → Surveyed Domain Names

Here you can directly view the data generated by the two domain names separately.

It was already displayed normally in the report at that time:

domain namePage views PVNumber of visitors UVNumber of IPSBounce rateAverage length of stay
www.shuijingwanwq.com21314213380.67%00:02:41
en.shuijingwanwq.com337766.67%00:04:57
Current summary24614914079.63%00:02:59
[Figure 11, Baidu statistics shows both www and en in the domain name report surveyed]
[Figure 11, Baidu statistics shows both www and en in the domain name report surveyed]

This shows that:

  • Baidu statistics have been collected normally for English domain names;
  • www and en can be viewed separately;
  • There is no problem with two domain names being classified into the same set of statistical codes;
  • With the addition of cross-domain monitoring, access identification between domain names will be more consistent.

13. The final result of this statistical adjustment

After the English site is migrated from /en/ to the en subdomain, the final configuration of Google Analytics and Baidu Statistics is as follows.

Google Analytics 4

Continue to use the original:

Plaintext
G-89CMTD9395

No new attributes are created, and no new data streams are created.

The default dimension of the ”Web page and Screen’ report is from:

Plaintext
网页路径和屏幕类

Adjusted to:

Plaintext
网页位置

You can directly view the full URL in the future to distinguish:

Plaintext
https://www.shuijingwanwq.com/...

with:

Plaintext
https://en.shuijingwanwq.com/...

Baidu Statistics

Continue to use the original statistical code:

Plaintext
abd646c01c6bac23ff98b9f3b12c32f1

in:

Usage Settings → Rule Settings → Cross-domain monitoring

Add in:

Plaintext
en.shuijingwanwq.com

Pass later:

Overview → Access Analysis → Surveyed Domain Names

Check the data of the Chinese station and the English station separately.


14. Summary

In this migration, there is no problem with the statistical code itself. What really needs to be adjusted is the way the background reports are viewed.

The original “Web page path” of GA4 is suitable for a single domain name or sub-directory structure, but after the English site is migrated to a separate subdomain, the same path may exist under www and en at the same time.

After changing the default dimension to “Web page location”, the complete domain name and page path will be displayed at the same time, making it more intuitive to view.

Baidu statistics continues to use the same set of codes, only need to increase cross-domain monitoring of English domain names, and view the two domain names separately through the “Surveyed domain Names” report.

In the end, this statistical adjustment has been completed:

Plaintext
GA4:
同一个属性
同一个数据流
同一个衡量 ID
默认显示完整网页位置

百度统计:
同一个统计站点
同一份统计代码
添加英文域名跨域监控
通过受访域名区分 www 与 en

For websites that migrate from the WordPress/en/ subdirectory to the English subdomain, this processing method can not only retain historical statistics, but also avoid data faults caused by re-splitting statistical items.

系列导航

需要长期技术维护或远程问题排查?

我是拥有 15+ 年经验的 PHP / Go 后端工程师,长期关注已有系统维护、Bug 修复、性能优化、服务器排查、WordPress 网站维护和小功能迭代。

如果你的项目遇到以下情况,可以先从一次小问题排查开始合作:

  • ✅ PHP / Laravel / Yii2 老项目无人维护
  • ✅ Go / Gin 后端接口需要排查或优化
  • ✅ WordPress 网站访问慢、报错或插件冲突
  • ✅ Nginx / MySQL / Redis / Linux 服务器异常
  • ✅ CDN / Cloudflare / DNS / HTTPS 配置问题
  • ✅ 需要长期远程技术支持或兼职维护

更多介绍请查看:关于我 & 合作

微信:13980074657
邮箱:shuijingwanwq@gmail.com
Telegram:@shuijingwan
GitHub:https://github.com/shuijingwan

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理