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

Integrating Analytics and Google AdSense Auto Ads Verification for a go-dev Single-Page Website

Figure 3: Baidu Analytics single page application settings

作者:

在

With the Chinese version of A Tour of Go deployed, go-dev.shuijingwanwq.com has entered a phase of continuous optimization.

Because A Tour of Go uses a Single Page Application (SPA) architecture to present course content, navigating between pages does not trigger a traditional full-page reload. Therefore, when integrating third-party analytics and advertising services, I needed to verify whether they could correctly recognize course page transitions.

This article documents a round of verification on go-dev after integrating Google Analytics, Baidu Analytics, and Google AdSense Auto Ads.

1. go-dev Single Page Application Structure

go-dev is deployed locally based on the original A Tour of Go architecture.

Course pages are switched dynamically:

  • The left side displays the course content;
  • The right side displays the Go Playground example;
  • After clicking Next, the course page is switched via front-end logic.

For example:

Plaintext
/tour/basics/16

↓

/tour/flowcontrol/1

The browser does not reload the entire site; it directly updates the current course state.

Therefore, traditional analytics and ad code that rely on page load events require additional verification.


2. Google Analytics 4 Single Page Analytics Verification

First, I verified whether Google Analytics 4 (GA4) could record SPA page transitions.

During testing, I observed the following request in the Network panel of the browser developer tools:

Plaintext
analytics.google.com/g/collect

After clicking Next, I could see:

  • The current page URL changes;
  • GA4 receives a new page_view request.

For example:

Plaintext
dl=https://go-dev.shuijingwanwq.com/tour/flowcontrol/1

dr=https://go-dev.shuijingwanwq.com/tour/basics/17

This indicates:

  • GA4 has correctly identified the SPA page transition;
  • No additional manual page tracking code is needed.
Figure 1: GA4 page_view request verification
Figure 1: GA4 page_view request verification

3. Baidu Analytics Single Page Application Support Verification

Baidu Analytics provides single page application tracking support.

After enabling:

Plaintext
Enable single page application data tracking

I continued testing course transitions.

Testing showed that after clicking Next, Baidu Analytics could send:

Plaintext
hm.baidu.com/hm.gif

requests.

The request parameters include:

Plaintext
su

and:

Plaintext
u

which correspond to:

  • The previous page;
  • The current page.

For example:

Plaintext
/tour/basics/17

↓

/tour/flowcontrol/1

This indicates that Baidu Analytics can now correctly record course page transitions.

Figure 2: Baidu Analytics SPA page request
Figure 2: Baidu Analytics SPA page request
Figure 3: Baidu Analytics single page application settings
Figure 3: Baidu Analytics single page application settings

4. Google AdSense Integration Testing

After completing the analytics verification, I continued testing Google AdSense.

go-dev currently uses:

Plaintext
Google AdSense Auto Ads

automatic ad mode.

When the page loads for the first time, it loads:

Plaintext
adsbygoogle.js

and initializes auto ads.

In the developer tools, you can see:

Plaintext
pagead2.googlesyndication.com

related requests.

This indicates:

  • The AdSense script loads normally;
  • The ad request pipeline is working normally.
Figure 4: AdSense script request
Figure 4: AdSense script request

5. Google Privacy Messaging Verification

On first visit, Google Privacy Messaging displays a privacy prompt.

This flow is part of the Google advertising system, used to handle user privacy choices.

After completing the prompt actions, ad requests continue to execute.

Figure 5: Google Privacy Messaging prompt
Figure 5: Google Privacy Messaging prompt

6. Auto Ads Interstitial Ad Testing

During testing, Google Auto Ads successfully displayed an interstitial ad.

The browser address bar showed:

Plaintext
#google_vignette

and displayed the Google automatic ad page.

This indicates:

  • The AdSense configuration is valid;
  • The site can now participate in ad serving normally;
  • The automatic ad system can recognize the current site.
Figure 6: Google Auto Ads interstitial ad display
Figure 6: Google Auto Ads interstitial ad display

7. Current In-Page Ad Status

Although Auto Ads can now work normally, in-page automatic ads have not yet displayed stably.

Inspecting via developer tools:

HTML
data-adsbygoogle-status="done"

data-ad-status="unfilled"

shows:

  • The ad code has executed;
  • Google has completed the ad request;
  • The current ad slot did not return any fill content.

This does not mean the configuration failed.

Possible reasons include:

  • The new site needs to accumulate data;
  • The current page structure is unique;
  • Insufficient ad inventory;
  • Google Auto Ads is still learning the page layout.

Therefore, I did not immediately adjust the ad code; instead, I will continue observing for a while.


8. Real Visitor Environment Testing

To rule out testing environment factors, I subsequently tested again using a normal browsing environment.

Results:

  • Page access is normal;
  • GA4 tracking is normal;
  • Baidu Analytics is normal;
  • Google AdSense requests are normal.

Currently, no anomalies have been found with the analytics and ad code integration.

Figure 7: Analytics requests in a real visitor environment
Figure 7: Analytics requests in a real visitor environment

9. Next Steps

go-dev has currently completed:

  • GA4 single page tracking verification;
  • Baidu Analytics single page support verification;
  • Google AdSense Auto Ads integration verification.

Next, I will continue to observe:

  1. Whether Auto Ads automatically increases in-page ads;
  2. Whether ads are re-identified after a single page transition;
  3. Whether adding fixed ad units is necessary.

If more precise control over ad placement is needed later, I can consider adding fixed ad areas within the course pages rather than relying entirely on Auto Ads.


Summary

This verification confirmed the compatibility of the A Tour of Go single page architecture with third-party services:

  • Google Analytics 4 can correctly record SPA page transitions;
  • Baidu Analytics single page application support works normally;
  • Google AdSense Auto Ads can load and display ads normally.

For single page sites that dynamically switch content using Go and JavaScript, analytics services typically need to focus on page transition events, while ad systems require continuous observation based on actual display performance.

go-dev currently has a complete analytics and advertising infrastructure in place, and the focus will now shift to user experience and ad display strategy optimization.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系